- #1
engineer_stud
- 8
- 0
Hi Guys!
I am trying to plot two different graphs in the same window using MATLAB. I have some constants that I declare, I then plot the graph from 0 to 15 seconds. Then I change two constants and plot another graph from 15 to 30. The units along the x-axis is Time (seconds) and velocity along (m/s) along the y axis.
The first graph seem to come out right, but the second is not. Don't know what is wrong. I believe I have written the function correctly.
This is my script :
clear all;
m = 200;
k = 100;
v0 = 0;
u = 200;
t = linspace(0,15,1500);
v = exp((-k/m)*t)*(v0-(u/k))+u/k;
figure(3);clf(3);
plot (t,v);
grid on;
hold on;
u = 0;
v0 = 2;
t = linspace(15,30,1500);
v = exp((-k/m)*t)*(v0-(u/k))+u/k;
plot(t,v);
ylabel('');
ylim([0 3]);
xlim([0 30]);
xlabel('');
title ('');
I am trying to plot two different graphs in the same window using MATLAB. I have some constants that I declare, I then plot the graph from 0 to 15 seconds. Then I change two constants and plot another graph from 15 to 30. The units along the x-axis is Time (seconds) and velocity along (m/s) along the y axis.
The first graph seem to come out right, but the second is not. Don't know what is wrong. I believe I have written the function correctly.
This is my script :
clear all;
m = 200;
k = 100;
v0 = 0;
u = 200;
t = linspace(0,15,1500);
v = exp((-k/m)*t)*(v0-(u/k))+u/k;
figure(3);clf(3);
plot (t,v);
grid on;
hold on;
u = 0;
v0 = 2;
t = linspace(15,30,1500);
v = exp((-k/m)*t)*(v0-(u/k))+u/k;
plot(t,v);
ylabel('');
ylim([0 3]);
xlim([0 30]);
xlabel('');
title ('');