[Scilab-users] evaluate matrix in a function
Rafael Guerra
jrafaelbguerra at hotmail.com
Sat Oct 7 18:51:00 CEST 2017
Hi,
It seems you are missing a few dots in g1, try:
g1=2*gx-(gx .*(1.25*gy-sqrt(abs(gx))))./abs(gx).^(3/2);
Also, I believe you should also remove the transposed input in V=g(r'), and make it V=g(r);
Rafael
and I believe your
-----Original Message-----
From: users [mailto:users-bounces at lists.scilab.org] On Behalf Of Hermes
Sent: Saturday, October 07, 2017 6:44 PM
To: users at lists.scilab.org
Subject: Re: [Scilab-users] evaluate matrix in a function
Hello
The H function works. the other two evaluations I can not solve the problem.
function val = H(z)
x=z(:,1);
y=z(:,2);
val=(1.25*y-sqrt(abs(x))).^2+x.^2-1;
endfunction;
function Sys=g(x)
gx=x(:,1);
gy=x(:,2);
g1=2*gx-(gx *(1.25*gy-sqrt(abs(gx))))/abs(gx).^(3/2);
g2=2.5*(1.25*gy-sqrt(abs(gx)));
Sys(:,1)=g1;
Sys(:,2)=g2;
endfunction
r=[3 1;4 2;3 5;8 2]
disp(H(r),"H");
H
8.232373
15.25
28.411865
63.107864
V=g(r');
disp(V,"g");
J = diffcode_jacobian(H,r);
disp(J, "Jacobian");
at line 4 of function g ( E:\Heart Curve8.sce line 28 )
at line 36 of executed file E:\Heart Curve8.sce
*Inconsistent row/column dimensions.
*
Gracias
More information about the users
mailing list