Azzera filtri
Azzera filtri

Info

Questa domanda è chiusa. Riaprila per modificarla o per rispondere.

Operands to the || and && operators must be convertible to logical scalar values. What is the error?

1 visualizzazione (ultimi 30 giorni)
Hi All, I am writing a following code and I am getting an error. Here is code
s=12/100;
h=1.2/100;
l2=3/100;l3=10/100;l4=6/100;
theta2=ones(1,361,'double');
theta3=ones(1,361,'double');
theta4=ones(1,361,'double');
for i=1:length(theta2)
theta2(i)=(i-1)*pi/180;
theta3(i)=120*pi/180;
theta4(i)=45*pi/180;
end
J1=ones(2,2,'double');
f1=ones(2,1,'double');
norm=1;num=1;
dtheta=zeros(1,2);
for i=1:361
it=1;norm=1;
while norm>0.01 && it<100
J1=[-l3*sin(theta3(i)),l4*sin(theta4(i));l3*cos(theta3(i)),-l4*cos(theta4(i))];
f1=-[s-l4*cos(theta4)+l3*cos(theta3)+l2*cos(theta2);h-l4*sin(theta4)+l3*sin(theta3)+l2*sin(theta2)];
dtheta=inv(J1)*f1;
theta3=dtheta(1,:)+theta3(i);
theta4=dtheta(2,:)+theta4(i);
norm=sqrt(dtheta(1,:).^2+dtheta(2,:).^2);
it=it+1;
end
end
Please help.

Risposte (1)

Azzi Abdelmalek
Azzi Abdelmalek il 18 Apr 2014
Use
while norm>0.01 & it<100
norm is a vector, what norm>0.01 means?
  2 Commenti
Sandip More
Sandip More il 18 Apr 2014
Norm is a magnitude of a vector and it is a measure of error in my problem. If I use & which is for a scalar, I don't get the expected results and some wired results appeared on screen.

Questa domanda è chiusa.

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by