필터 지우기
필터 지우기

Multiple runs changing variable for plot

조회 수: 2 (최근 30일)
Gordon North Piegan
Gordon North Piegan 2020년 3월 25일
답변: Star Strider 2020년 3월 25일
I'd like to re-run my code each time for multiple variables. Yes, I know that I could use a for loop for this, but because my code is complex and has a long run time as is
it would be inefficient to use a for loop. So I would like to run the code for a parameter. Then, re-run the code again and draw over the current plot. However, every time I re-run the code instead of plotting the new data over the previous data I have new plots open up. I'm trying to compare how changing incident angle of a bragg reflector shifts the "filter" to the right for angles in the range of 0-60 degrees. So it's ideal that each run plots over the last run. Here is plot code so far.
%Plot the data on two seperate graphs.
figure()
subplot(2, 1, 1)
hold on
plot(range, ref_data_reflection_S)
title("Perpendicular Reflection Magnitude")
%xlabel("Incident wavelength (meters)")
ylabel("Perpendicular Reflection Magnitude")
subplot(2, 1, 2)
hold on
plot(range, ref_data_transmission_S)
title("Perpendicular Transmission Magnitude")
%xlabel("Incident wavelength (meters)")
ylabel("Perpendicular Transmission Magnitude")

답변 (1개)

Star Strider
Star Strider 2020년 3월 25일
I would use savefig for each figure you want to compare later. All the data and related information as well as the figure itself will be stored in each .fig file. Load each with openfig when you want to view them.
Getting the data from them is not trivial, although it is not difficult. See the findobj function (and myriad Answers here for reference) to retrieve those data.

카테고리

Help CenterFile Exchange에서 Subplots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by