Error using plot, vectors must be the same lengths?

2 views (last 30 days)
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 Comments
Michael Buls
Michael Buls on 6 Dec 2019
Edited: Michael Buls on 6 Dec 2019
they are all 1 value off of eachother, 5767, 5766. 5765

Sign in to comment.

Accepted Answer

Ridwan Alam
Ridwan Alam on 6 Dec 2019
Edited: Ridwan Alam on 6 Dec 2019
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 Comments

Sign in to comment.

More Answers (0)

Categories

Find more on Programming 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!