Error using plot Vectors must be the same lengths

Hi,,
iam not matlab pro. :)
so i have problem on a very simple program
that's the program >>>>>>>>>>>>>>>>
vo=input('vo=');
vf=input('vf=');
to=input('to=');
tf=input('tf=');
qo=input('qo=');
qf=input('qf=');
ao=qo;
a1=diff(qo);
syms t;
syms dis;
a2=(3*(qf-qo)-(2*diff(qo)+diff(qf))*tf)/((tf)^2);
a3=(-2*(qf-qo)+(diff(qo)+diff(qf))*tf)/(tf)^3;
dis=ao+a1*t+a2*t^2+a3*t^3;
vel=a1+2*a2*t+3*a3*t^2;
acc=2*a2+6*a3*t;
t=0:tf;
plot(dis,t);
when i press play this error shown to me " Error using plot Vectors must be the same lengths "
so please how can i edit this program to playing well

 Akzeptierte Antwort

Walter Roberson
Walter Roberson am 12 Apr. 2013

0 Stimmen

ndis = double( subs(dis, 't', t) );
plot(ndis, t);

9 Kommentare

koke
koke am 12 Apr. 2013
tahnx for your interest but that's doesn't solving the problem it's still give me the same error after i adding your solution best regard :)
What does size(ndis) and size(t) show ?
koke
koke am 12 Apr. 2013
ndis 0*0 double t 1*11 double
Walter Roberson
Walter Roberson am 12 Apr. 2013
Bearbeitet: Walter Roberson am 12 Apr. 2013
Could you show us what "dis" is before the plot?
What exactly are you entering in response to the prompt for qo ?
koke
koke am 12 Apr. 2013
Bearbeitet: koke am 12 Apr. 2013
the input of qo is = 10
koke
koke am 12 Apr. 2013
this is photos for the program and the command window i hope it can help you :) http://www.4shared.com/photo/Ssefu_Oa/mat.html http://www.4shared.com/photo/V-_1okfV/mat2.html
if q0 is 10, then what are you expecting the result of diff(q0) to be ?
koke
koke am 12 Apr. 2013
the diff of qo = 0
diff() of a scalar numeric value is [] the empty list, because diff() of numerics is the subtract-adjacent operation.
If q0 had been assigned the symbolic value 0, sym('0') then diff() of that would likely generate an error because there would not be any variable contained inside it for the symbolic calculus differential operator to choose to take the differential with respect of.
If you had specified a variable, such as diff(sym('0'), sym('t')) then the result would be (symbolic) 0.
Likewise for the other variables you are taking diff() of. It does not seem productive to bother to use diff() to calculate what you know will be 0... unless you are wanting the user to be able to enter NaN in which case the calculus differential would be NaN instead of 0.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Mathematics finden Sie in Hilfe-Center und File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by