Error using plot Vectors must be the same lengths
조회 수: 1 (최근 30일)
이전 댓글 표시
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
댓글 수: 0
채택된 답변
Walter Roberson
2013년 4월 12일
ndis = double( subs(dis, 't', t) );
plot(ndis, t);
댓글 수: 9
Walter Roberson
2013년 4월 12일
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개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Calculus에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!