MATLAB time (seconds) vs velocity graph plotting questions
Mostrar comentarios más antiguos
Hi guys, I'm enquiring about a section of my homework again and its asking that I use strictly array creation and concatenation to plot the graph of the following question:

and the code I've written to try and solve this via youtube tutorials and lots of websites is:
%time interval of 0.1 seconds
dt=0.1;
%time establishment in intervals of 0.1 seconds
t1=0:dt:10;
t2=10:dt:15;
t3=15:dt:20;
%acceleration establishment
a1=ones(1,length(t1))*10;
a2=ones(10,length(t2))*15;
a3=ones(15,length(t3))*20;
axis([0 20 4 12])
hold on
plot([10 10],[5,10])
hold off
v1=cumtrapz(a1)*dt;
v2=cumtrapz(a2)*dt;
v3=cumtrapz(a3)*dt;
plot(t1,v1,t2,v2,t3,v3)
and the result i get is:

can anyone please tell me where im going wrong and what I need to do to fix, any help is appreciated, thankyou in advance <3
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Programming en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!