Index exceeds array dimensions. Index value 9 exceeds valid range [1-1] for array 'm2'.

1 view (last 30 days)
I have tried to solve my problem many times but matlab throws this error, someone can help me please.
Error: "Index exceeds array dimensions. Index value 9 exceeds valid range [1-1] for array 'm2'."
function [dd_theta1,dd_theta2]=ss_barra1(T1,T2,d_theta1,theta1,dd_theta2 ,d_theta2,theta2)
%Los valores de las constantes que definen al robot son:
l1 = 2; % longitud en metros
l2 = 1; % longitud en metros
g = 9.81; % aceleración de la gravedad m/s^2
m1 = 2; % masa en kg
m2 = 1; % masa en kg
dd_theta1=(T1-m2*(l1*l2*cos(theta2)+(l2^2))*dd_theta2+m2*l1*l2*sin(theta2)*(2*d_theta1*d_theta2+(d_theta2^2))+(m1+m2)*l1*g*cos(theta1)+m2*g*l2*cos(theta1+theta2))/(m1*(l1^2)+m2((l1^2)+2*l1*l2*cos(theta2)+(l2^2)));
dd_theta2=(T2-m2*(l1*l2*cos(theta2)+(l2^2))*dd_theta1-m2*l1*l2*sin(theta2)*(d_theta1^2)-m2*g*l2*cos(theta1+theta2))/(m2*(theta2^2));

Answers (1)

Walter Roberson
Walter Roberson on 27 May 2023
m2((l1^2)
MATLAB has no implied multiplication. That is a request to index m2

Tags

Products


Release

R2023a

Community Treasure Hunt

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

Start Hunting!