Unable to perform assignment because the left and right sides have a different number of elements.
1 次查看(过去 30 天)
显示 更早的评论
I want to make a function tha carculates de speed of a train that accelerates uniformly en every point of the train having acceleration(a), train length (Lt) and start speed (v0) as inputs and i don t know why this error appears.
Does anyone know how to solve this?
Thanks
ERROR:Unable to perform assignment because the left and right sides have a different number of elements.
Error in VelTren (line 9)
v(i)=((v0.^2)+2*a*l).^(1/2);
function [v] = VelTren(v0,a,Lt)
l=0:0.1:Lt;
v=zeros(1,length(l));
v(1)=v0;
for i=2:length(l)
v(i)=((v0.^2)+2*a*l).^(1/2);
end
end
0 个评论
采纳的回答
Kevin Holly
2023-2-22
VelTren(1,9.81,46)
You need to change l to l(i).
function [v] = VelTren(v0,a,Lt)
l=0:0.1:Lt;
v=zeros(1,length(l));
v(1)=v0;
for i=2:length(l)
v(i)=((v0.^2)+2*a*l(i)).^(1/2);
end
end
0 个评论
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!