Multiple figures updated with each for-loop iteration

1 回表示 (過去 30 日間)
Mary Houston
Mary Houston 2018 年 8 月 21 日
回答済み: Julie 2018 年 8 月 21 日
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 Center および File ExchangeGraphics Objects についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by