How do I programmatically print scope to a figure?

조회 수: 3 (최근 30일)
Gaddiel Kamto
Gaddiel Kamto 2022년 11월 29일
댓글: cr 2022년 12월 5일
Hello,
I am trying to do what this button does from matlab
After some research in the online community, that is the only way I found to extract the data used by the scope to plot the lines, i.e. by getting the figure handles and looking into the axes children. Haven't found a way to do the same directly through the scope, which is why I am trying to copy the scope to a figure.
I found these set of commands online which does something similar,
% Get the name of the Scope of interest
scopeName = get_param(gcb,'Name');
% Find the Scope (which is really just a figure window)
hs = findall(0,'Name',scopeName);
% Create a new target figure
hf = figure('Position',get(hs,'Position'));
% Get the handle to the panel containing the plots
hp = findobj(hs.UserData.Parent,'Tag','VisualizationPanel');
% Copy the panel to the new figure
copyobj(hp,hf)
but the resulting figure no longer has the XY data when I try
findall(hf,'Type','line') or
findall(hf,'Type','stair')
Note that the above command works on the manually created figure (by clicking the 'Print to Figure' button)
Thanks
  댓글 수: 4
Mathieu NOE
Mathieu NOE 2022년 12월 5일
why would you need to delete the 'To Workspace' blocks ?
cr
cr 2022년 12월 5일
Just log the signals.

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

답변 (0개)

카테고리

Help CenterFile Exchange에서 Interactive Control and Callbacks에 대해 자세히 알아보기

제품


릴리스

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by