Info
Cette question est clôturée. Rouvrir pour modifier ou répondre.
Index exceeds the number of array elements (1)
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
function [] = diggerangle(L_12, L_23, L_13, x)
iteration_limit = 20;
tolerance = 10^-7;
x = [x(1)*(pi/180);x(2)*(pi/180)];
for count = 1:iteration_limit + 1
if count == iteration_limit + 1
error('Iteration limit reached. Iteration did not converge.')
end
f = [L_12*cos(x(1))-(L_13)-L_23*cos(x(2));...
L_12*sin(x(1))-L_23*sin(x(2))];
if abs(f)<tolerance
break
end
df = [-L_12*sin(x(1))+L_23*sin(x(2));...
L_12*cos(x(1))-L_23*cos(x(2))];
x = x - inv(df)*f;
end
x(1);
x(2);
x(1)*(180/pi)
x(2)*(180/pi)
end
2 commentaires
Réponses (1)
the cyclist
le 25 Mar 2020
You didn't answer Ameer's first question, but it seems clear that when you call the function
diggerangle(L_12, L_23, L_13, x) % what are the inputs here?
that the value of x is simply a scalar, and not a vector. Therefore,
x(2)
is going to give an error, because x only has one element.
0 commentaires
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!