Error Inner Matrix Dimensions must agree?? Help!
Mostrar comentarios más antiguos
So i am trying to solve for these 2 values but i keep getting an error aobut my matrix dimensions. i dont know why, i will attach what my x value is.
----------------------------------------------
Error using * Inner matrix dimensions must agree.
----------------------------------------------
ang_position=x(:,1);
ang_velocity=x(:,2);
ang_accel= diff(ang_velocity);
a_cmx= (ang_accel.*(L./2).*cos(ang_position))-((ang_velocity.^2)*(L/2)*sin(ang_position));
a_cmy= (-ang_accel.*(L./2).*sin(ang_position))-((ang_velocity.^2)*(L/2)*cos(ang_position));

Respuesta aceptada
Más respuestas (1)
Azzi Abdelmalek
el 29 de Jul. de 2014
A=1:5
B=diff(A)
Notice that A and B haven't the same size
2 comentarios
Azzi Abdelmalek
el 29 de Jul. de 2014
Editada: Azzi Abdelmalek
el 29 de Jul. de 2014
You should reduce the size of all your initial array, even L if it's an array. There are also errors in your code
If L is an array, use L(1:end-1)
x=rand(10,2);
ang_position=x(:,1);
ang_velocity=x(:,2);
ang_accel= diff(ang_velocity);
ang_position1=ang_position(1:end-1)
ang_velocity1=ang_velocity(1:end-1)
a_cmx= (ang_accel.*(L./2).*cos(ang_position1))-((ang_velocity1.^2).*(L/2).*sin(ang_position1));
a_cmy= (-ang_accel.*(L./2).*sin(ang_position1))-((ang_velocity1.^2).*(L/2).*cos(ang_position1));
David
el 29 de Jul. de 2014
Categorías
Más información sobre Logical en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!