Using savefig in live editor

조회 수: 9 (최근 30일)
RobbieC
RobbieC 2020년 9월 25일
답변: Walter Roberson 2020년 9월 25일
Hello,
The following code segment works fine in the MATLAB command window. It produces the expected figure and saves it. The saved figure, TdfOverlayPspec.fig, can be opened (open('TdfOverlayPspec.fig')) and is the same figure that was saved.
When this same code segment is run in LIVE EDITOR, it produces the TdfOverlayPspec.fig file, but the file does not open. There is no error reported and the 'open' command appears to be executed but no figure is displayed. I have checked to see if it was produced off monitor and this is not the case.
The file, TdfOverlayPspec.fig, produced is the same size whether generated from the MATLAB command window or for LIVE EDITOR.
Looking forward to any help you can provide.
Thanks,
RC
% Power Spectrum
figure
pspectrum(output.TDF_MTL_output,Fs,'FrequencyResolution',50e3);
% Add the system generator result on the same graph as the MATLAB model.
hold on;
% Display the overlay MATLAB and System Generator TDF output power spectrum
pspectrum(TDF_SG_Out_Cmplx,Fs,'FrequencyResolution',50e3);
legend('ML TDF Out','SG TDF Out','location',"southeast");
text (0.01, 0.9, {'Overlay plot of TDF Output', 'Complex Output From','MATLAB and System Generator'},...
'Units',"normalized","Interpreter","latex",...
"VerticalAlignment","middle","BackgroundColor",[0.9,0.9,0.9]);
% Save figure when enabled.
if SaveMATLABmatFile == 1
savefig(fullfile(TDF_figs_folder,'TdfOverlayPspec'));
end
% Close all figures
close
hold off;
  댓글 수: 2
Walter Roberson
Walter Roberson 2020년 9월 25일
check to see if the loaded figure exists but has visible off
RobbieC
RobbieC 2020년 9월 25일
Thank you for your comment Walter.
Though the default for the visibililty property is 'on' for the figure command, this apparently is not true when running in the live editor. By changing the command to figure("Visible","on"), the saved figure became visible when opened.
Again, thank you for your help.
RC

댓글을 달려면 로그인하십시오.

채택된 답변

Walter Roberson
Walter Roberson 2020년 9월 25일
When loading a figure does not appear to create the figure, but gives no error, then check whether the figure exists but has 'visible' set to off.

추가 답변 (0개)

카테고리

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

태그

제품


릴리스

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by