Filter löschen
Filter löschen

Multiple figures updated with each for-loop iteration

3 Ansichten (letzte 30 Tage)
Mary Houston
Mary Houston am 21 Aug. 2018
Beantwortet: Julie am 21 Aug. 2018
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

Akzeptierte Antwort

Julie
Julie am 21 Aug. 2018
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

Weitere Antworten (0)

Community Treasure Hunt

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

Start Hunting!

Translated by