help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

How to use a returning vector function inside another returning vector f


From: Adhanedhel
Subject: How to use a returning vector function inside another returning vector function ?
Date: Mon, 31 Jul 2017 07:54:00 -0700 (PDT)

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



--
View this message in context: 
http://octave.1599824.n4.nabble.com/How-to-use-a-returning-vector-function-inside-another-returning-vector-function-tp4684280.html
Sent from the Octave - General mailing list archive at Nabble.com.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]