Multiple figures updated with each for-loop iteration

1 次查看(过去 30 天)
I would like to output two figures, each of which needs to be added to for each iteration of a for-loop. So figure 1 has data from all iterations as does figure 2. As of now my code outputs a total of 4 figures (# of desired figures * # of iterations).
Here is my not so functional code:
for i1 = 1:2 % Starting values B = 60; % a touch less than MPF Uo = [Yo Vo(i1) yo]; % Initial conditions, Entry angle, Velocity, height q_max = 0; accel_max2 = 0; accel_lim = 15*g_E; q_lim = 210*100^2; % meters
while (q_max < q_lim) && (accel_max2 < accel_lim^2) [U_maxheat, Rho_maxheat, Uout, tout, q_tot, q_conv, q_rad, accel] = PeakHeat2030(Uo, LDmax, B, Ac, Ar); accel_max2 = max(accel.*accel); q_max = max(q_tot); B = B + 2; % increase B end
disp(B-2); figure('name','Acceleration'); plot(tout(1:end-1),accel./g_E) hold on xlabel('Time [s]') ylabel('Acceleration [Earth gravity]') title('Earth Gravity Experienced')
figure('name','Heating'); plot(tout,q_tot) hold on xlabel('Time [s]') ylabel('Heat transfer [W/cm^2]') title('Total Heating') end

采纳的回答

Julie
Julie 2018-8-21
figure(1)
hold on
figure(2)
hold on
for i1 = 1:2 % Starting values B = 60; % a touch less than MPF Uo = [Yo Vo(i1) yo]; % Initial conditions, Entry angle, Velocity, height q_max = 0; accel_max2 = 0; accel_lim = 15*g_E; q_lim = 210*100^2; % meters
while (q_max < q_lim) && (accel_max2 < accel_lim^2) [U_maxheat, Rho_maxheat, Uout, tout, q_tot, q_conv, q_rad, accel] = PeakHeat2030(Uo, LDmax, B, Ac, Ar); accel_max2 = max(accel.*accel); q_max = max(q_tot); B = B + 2; % increase B end
disp(B-2); figure(1); plot(tout(1:end-1),accel./g_E) hold on xlabel('Time [s]') ylabel('Acceleration [Earth gravity]') title('Earth Gravity Experienced')
figure(2); plot(tout,q_tot) hold on xlabel('Time [s]') ylabel('Heat transfer [W/cm^2]') title('Total Heating') end

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Graphics Objects 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by