# How to use a returning vector function inside another returning vector function ?

2 messages
Open this post in threaded view
|
Report Content as Inappropriate

## How to use a returning vector function inside another returning vector function ?

 I have the following toy-code %%%%%%%%%%%%%%%% function test         for i=1:2                 x(i,1)=rand();                 dx(i,1)=rand();         end         for epsi=10.^[-1:-1:-5]                                 epsi                 Norm = norm((G(x+epsi*dx,z)-G(x-epsi*dx,z))/(2*epsi) - dG(x,z)*dx)                 z         end end %--------------------------------------------- %--------------------------------------------- %--------------------------------------------- function Res = G(x,z) for i=1:2         Res(i,1) = x(i,1)^2+z(i,1); end         end function Res=dG(x) for i=1:2         Res(i,i) = 2*x(i,1); end         end function Res = z         for i=1:2                 Res(i,1) = 10*i*y(i,1);         end end function Res = y         for i=1:2                 Res(i,1) = i;         end end %%%%%%%%%%%%%%%%%%%% The errors are : error: z: =: nonconformant arguments (op1 is 1x1, op2 is 2x1) error: called from     testy>z at line 48 column 12     testy at line 14 column 6 My goal here is to use the "vector-function" y inside the function z which is itself used in G, to check that dG is the jacobian matrix of G (of course here is a simple example where it is useless to check,  which is not the case of my real functions). Here the variable for my jacobian is only the vector x, and y and z are side functions. Can you help me, and explain me how to write properly what i want to do ? Adhanedhel