How to plot using a loop on the same axis
Show older comments
Would like to plot without having to hard code every single line up to 20+ customers(20 x 1 structure). Had an attempt at a for loop, the error message states that the number of element on the right are not same as on the left
%Graphical representation
t = 0:0.1:310; % Time vector for plots (m)
[position1,speed1,Duration1] = calcFallForPerson(customer(1),4200,0.1,1500);
[position2,speed2,Duration2] = calcFallForPerson(customer(2),4200,0.1,1500);
[position3,speed3,Duration3] = calcFallForPerson(customer(3),4200,0.1,1500);
[position4,speed4,Duration4] = calcFallForPerson(customer(4),4200,0.1,1500);
figure(1)
plot(t,position1,t,position2,t,position3,t,position4)
title('Posiion')
xlabel('Time(s)')
ylabel('Postion(m)')
xlim([0 320])
ylim([0 4500])
figure(2)
plot(t,speed1,t,speed2,t,speed3,t,speed4)
title('Velocity')
xlabel('Time(s)')
ylabel('Velocity(m/s)')
xlim([0 320])
ylim([0.0 60.0])
xlim([0 320])
ylim([0.0 60.0])
Accepted Answer
More Answers (0)
Categories
Find more on Loops and Conditional Statements 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!