How do I programmatically print scope to a figure?

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 年 11 月 30 日
hello
why not simply use a 'To Workspace' blocks in parallel to your Scope ?
then you have the data available in your workspace and you can move on from there
Gaddiel Kamto
Gaddiel Kamto 2022 年 12 月 1 日
That could certainly work.
The workflow I had begun was hinging on the first method of getting the data from figure directly, which is why I asked the question.
Not sure which would be more efficient though: adding/deleting 'To Workspace' blocks and processing the data in Workspace or extracting the data directly from the scopes/figures.
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 件)

カテゴリ

ヘルプ センター および File ExchangeInteractive Control and Callbacks についてさらに検索

製品

リリース

R2020b

質問済み:

2022 年 11 月 29 日

コメント済み:

cr
2022 年 12 月 5 日

Community Treasure Hunt

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

Start Hunting!

Translated by