Unable to perform assignment because the left and right sides have a different number of elements.
1 view (last 30 days)
Show older comments
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 Comments
Accepted Answer
Kevin Holly
on 22 Feb 2023
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 Comments
More Answers (0)
See Also
Categories
Find more on Powertrain Blockset in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!