Error using plot, vectors must be of the same length
Show older comments
I know this basically means that the two outputs are of different vector lengths so cant be plotted against each other, however i am not sure how to fix this in my coding, shown below. Thanks in advance for any advice!
R=input('Enter the radius of the turn > '); chim=input('Enter the angle of the turn > '); vf=input('Enter the velocity of the vehicle > '); %tmax=input('Enter the total manoeuvre time > '); dt=input('Enter the time increment for the discretisation > ');
chidm=vf/R; k=0.15; t1=2*k*((chim)/(chidm)); t2=t1+(2*R*chim*(1-(2*k)))/(2*vf); tmax=360; a1=(-2*chidm)/(t1^3); b1=3*chidm/(t1^2); a3=(2*chidm)/(tmax-t2)^3; b3=(-3*(t2+tmax)*chidm)/(tmax-t2)^3; c3=(6*t2*tmax*chidm)/(tmax-t2)^3; d3=chidm-((chidm*(3*tmax-t2)*t2^2)/(tmax-t2)^3);
global t mpts t=0 : dt : tmax; mpts=length(t);
if t>=0 & t<=t1 chid=a1*t.^3+b1*t.^2; chi=(1/4)*a1*t.^4+(1/3)*b1*t.^3; elseif t1<t & t<t2 chid=chidm; chi=chidm*t; elseif t2<=t & t<=tmax chid=a3*t.^3+b3*t.^2+c3*t+d3; chi=((1/4)*a3*t.^4)+((1/3)*b3*t.^3)+((1/2)*c3*t.^2)+(d3*t); end
plot(t,chid),xlabel('t (s)'),ylabel('chid (deg/s)')
Accepted Answer
More Answers (1)
Image Analyst
on 17 Nov 2015
0 votes
Then you'll be able to find out why t and chid are different lengths.
Categories
Find more on Annotations 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!