Hello,
I'm trying to plot a time to velocity graph where the velocity is calculated from 3 equations. The three equations are:
This is what my code looks like:
clccleartime = [0:0.1:25];velocity = zeros(length(time),1);for t = time if t <= 5 velocity = 0.1553567*time.^6 - 2.0416*time.^5 + 9.1837*time.^4 - 14.829*time.^3 - 1.3703*time.^2 + 32.821*time - 1.3155; elseif (5<t) && (t<=15.4) velocity = 0.003980879*time.^5 - 0.2247*time.^4 + 4.8682*time.^3 - 50.442*time.^2 + 254.67*time - 430.66; else velocity = -0.073*time.^2 + 6.1802*time + 40.423; end endplot(time,velocity)
For some reason all the time seems to go through the else statement. Can anyone please help me out, I've been struggling on this simple code for a while now. The graph should also look something similar to this:
Best Answer