MATLAB Answers

need help with basic speed time graph plot

9 views (last 30 days)
Ben Newton
Ben Newton on 5 Nov 2019
Commented: Rena Berman on 12 Dec 2019
need to make a subplot for this speed equation over 0 to 8 seconds, but all i get is a blank graph. i think its because the graph is zoomed in on a specific area, any idea how to plot one that can be seen??
t = 0:0.05:8;
s = @(t)((0.0041*t^6) - (0.1383*t^5) + (1.6963*t^4) - (8.915*t^3) + (13.961*t^2) + (40.96*t))/2.237;
subplot(1,2,1)
plot(t,s(t))
title('speed vs time')
xlabel('time (Seconds)')
ylabel('speed (m/s)')
grid on;

  2 Comments

Stephen Cobeldick
Stephen Cobeldick on 8 Nov 2019
Original question:
need to make a subplot for this speed equation over 0 to 8 seconds, but all i get is a blank graph. i think its because the graph is zoomed in on a specific area, any idea how to plot one that can be seen??
t = 0:0.05:8;
s = @(t)((0.0041*t^6) - (0.1383*t^5) + (1.6963*t^4) - (8.915*t^3) + (13.961*t^2) + (40.96*t))/2.237;
subplot(1,2,1)
plot(t,s(t))
title('speed vs time')
xlabel('time (Seconds)')
ylabel('speed (m/s)')
grid on;

Sign in to comment.

Accepted Answer

Richard Brown
Richard Brown on 5 Nov 2019
Your function needs to have elementwise powers, i.e. use .^ instead of ^
It's trying to do matrix powers of the vector of time values, which doesn't make sense.

  0 Comments

Sign in to comment.

More Answers (0)

Tags


Translated by