Vectors as input and output in a function
Mostrar comentarios más antiguos
I am calling this function in another script. The function is called 'a.m' and is in the same folder as the script. aceleracion should be an output vector and u is an input vector. I am getting the following error:
Unable to perform assignment because the indices on the left side are not compatible with the size of
the right side.
Error in a (line 11)
aceleracion(indtiempo)=h*w*cos(w*u(indtiempo)-pi);
Error in Encoder_interpolacion_lineal_online_y_offline_con_aceleracion (line 319)
aang=a(taang);
Thanks in advance.
function [aceleracion] = a(u)
global periodo;
global h;
global w;
for indtiempo=1:length(u)
if u(indtiempo)<=periodo/2
aceleracion(indtiempo)=h*w*cos(w*u(indtiempo));
else
aceleracion(indtiempo)=h*w*cos(w*u(indtiempo)-pi);
end
end
end
2 comentarios
Walter Roberson
el 28 de Mayo de 2021
Put a breakpoint in at the for loop. When the code stops, examine
size(periodo)
size(h)
size(w)
size(w)
Luciano Montanelli
el 28 de Mayo de 2021
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre MATLAB 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!
