How can I fix the 'saveas' code to save pdf-files containing simulink simulation results by using 'strcat'?
조회 수: 1 (최근 30일)
이전 댓글 표시
Hello people,
I am struggled with the following code:
function nightly_simulation_Callback(hObject, eventdata, handles)
open_system('SimulinkModel.slx');
sim('SimulinkModel.slx');
hFig = findall(0,'tag','SIMULINK_SIMSCOPE_FIGURE');
name = strcat('NCSSimResults','_',num2str(1));
saveas(hFig, name, 'pdf');
I don't understand why the 'saveas' function doesn't work although I gave proper file name, file type and the figure of graphical simulation results of a Simulink model. Do I need to change something in 'strcat' code or? Also I hope that someone helps me in this issue.
Resulted errors:
Error using checkArgsForHandleToPrint
Handle input must be scalar, vector, or cell array of vectors.
Error in checkArgsForHandleToPrint
Error in print>LocalCreatePrintJob (line 100)
handles = checkArgsForHandleToPrint(0, varargin{:});
Error in print (line 38)
[pj, inputargs] = LocalCreatePrintJob(varargin{:});
Error in saveas (line 181)
print( h, name, ['-d' dev{i}] )
Error in GUI>nightly_simulation_Callback (line 909)
saveas(hFig, name, 'pdf');
Error in gui_mainfcn (line 95)
feval(varargin{:});
Error in GUI (line 43)
gui_mainfcn(gui_State, varargin{:});
Error in
matlab.graphics.internal.figfile.FigFile/read>@(hObject,eventdata)GUI('nightly_simulation_Callback',hObject,eventdata,guidata(hObject))
Error while evaluating DestroyedObject Callback.
댓글 수: 0
답변 (1개)
Steven Lord
2019년 8월 9일
What is the size of hFig? Is it a "scalar, vector, or cell array of vectors"? You can check the first two with isscalar and isvector.
참고 항목
카테고리
Help Center 및 File Exchange에서 Simulink Environment Customization에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!