The sizes of the second and third arguments are inconsistent. using syms

6 Ansichten (letzte 30 Tage)
The error is showing up in line #39 i.e { J1=subs(J,var,var1); } . Error shows up as :
Error using sym/subs>normalize (line 216) The sizes of the second and third arguments are inconsistent.
Error in sym/subs>mupadsubs (line 147) [X2,Y2,symX,symY] = normalize(X,Y); %#ok
Error in sym/subs (line 135) G = mupadsubs(F,X,Y);
Error in method2 (line 39) J1=subs(J,var,var1);
if true
function var1=tempfile12345()
bx=1;
by=1;
l1=2;
l2=3;
ex=3;
ey=4;
syms th1 th2 th3 real
var=[th1 th2 th3 ]'; % variables matrix
f(1,1)= 2*bx+l1*cos(th1)+l2*cos(th1+th2+th3)-ex; %functions array
f(2,1)= by+l1*sin(th1)+l2*sin(th1+th2+th3)-ey ; %functions array
var1 =[0.1 0.1 0.1 ]';
tol=0.0001;
nmax=30;
numvar=length(var);
numeq=length(f);
for j=1:numeq
for i=1:numvar
J(j,i)=diff(f(j),var(i));
end
end
n=0;
dmain=0.1*ones(size(var,1),1);
while(any(abs(dmain)>tol)&&(n<nmax))
f1=subs(f,var,var1);
J1=subs(J,var,var1);
dmain=pinv(J1)*f1;
var1=var1-dmain;
n=n+1;
end
if(n==nmax)
error('no feasible solution');
end
return
end

Antworten (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by