Multiple figures updated with each for-loop iteration

조회 수: 5 (최근 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 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