Error using plot, vectors must be the same lengths?

조회 수: 2 (최근 30일)
Michael Buls
Michael Buls 2019년 12월 6일
댓글: Ridwan Alam 2019년 12월 6일
g = 9.81;
theta = pi/4;
v = 400;
tmax = ((2*v*sin(theta))/g);
[x, y, t] = projectileMotion(400, pi/4);
[dfx] = derivative(t, y);
[ddfx] = derivative(t, dfx);
plot(y, dfx, ddfx)
xlabel('Time (sec)')
ylabel('y, dy, ddy')
title('Position, Velocity and Acceleration in vertical direction')
When i do this I get the error in the title, please help. Im calling functions that I have already made.
  댓글 수: 2
Ridwan Alam
Ridwan Alam 2019년 12월 6일
what is the size of y, dfx, and ddfx?
Michael Buls
Michael Buls 2019년 12월 6일
편집: Michael Buls 2019년 12월 6일
they are all 1 value off of eachother, 5767, 5766. 5765

댓글을 달려면 로그인하십시오.

채택된 답변

Ridwan Alam
Ridwan Alam 2019년 12월 6일
편집: Ridwan Alam 2019년 12월 6일
Plot() doesn't allow the syntax plot(y1,y2,y3). https://www.mathworks.com/help/matlab/ref/plot.html
If t, y, dfx, and ddfx are of same length, you can try:
plot(t,y,'r',t,dfx,'g',t,ddfx,'b');
Or use
hold on;
  댓글 수: 4
Michael Buls
Michael Buls 2019년 12월 6일
Awesome, thanks for the help!
Ridwan Alam
Ridwan Alam 2019년 12월 6일
Sure. Glad it worked.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Programming에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by