Vectors as input and output in a function
Mostra commenti meno recenti
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 Commenti
Walter Roberson
il 28 Mag 2021
Put a breakpoint in at the for loop. When the code stops, examine
size(periodo)
size(h)
size(w)
size(w)
Luciano Montanelli
il 28 Mag 2021
Risposta accettata
Più risposte (0)
Categorie
Scopri di più su MATLAB in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
