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

 采纳的回答

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

9 个评论

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 ?
ndis 0*0 double t 1*11 double
Could you show us what "dis" is before the plot?
What exactly are you entering in response to the prompt for qo ?
the input of qo is = 10
if q0 is 10, then what are you expecting the result of diff(q0) to be ?
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.

请先登录,再进行评论。

更多回答(0 个)

类别

帮助中心File Exchange 中查找有关 Mathematics 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by