0
在Simulink Scope
內部,可以選擇Print to Figure
。這將打開一個與原始範圍內容相同的圖形。有沒有辦法以編程方式執行此操作?如何以編程方式在Simulink示波器中打印圖形
也this help page,this help page和this page見。
在Simulink Scope
內部,可以選擇Print to Figure
。這將打開一個與原始範圍內容相同的圖形。有沒有辦法以編程方式執行此操作?如何以編程方式在Simulink示波器中打印圖形
也this help page,this help page和this page見。
取決於你想要/需要得到多少花式。
如果你真的想使用完全相同的代碼作爲UI回調,那麼你就需要研究如何在以下目錄/包使用回調函數:
MATLABROOT \工具箱\共享\ spcuilib + matlabshared +示波器\ @UnifiedScope
特別是,printToFigureCallback.m
是由回調調用的代碼。 (你可以在代碼中放置一個斷點,然後使用調試器來遍歷代碼,看它是如何工作的。)
看起來好像下面的東西應該可以工作,但它不會,所以你會需要做一些試驗和錯誤調查,使其工作。
% 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);
% Print to a figure.
printToFigureCallback(h.UserData)
另外,一個更簡單的,儘管可能不太令人滿意的解決方案,將做到以下幾點:
% 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)
根據您的要求,那麼你可能要玩弄一些單位,以確保調整數字的大小是正確的。
對於我的應用程序來說,以編程方式打印圖形似乎是矯枉過正。感謝這些有趣的信息,我可能會在其他情況下使用它。 – Karlo
第一個確實給出了一個錯誤(「未定義函數'printToFigureCallback',用於'double'類型的輸入參數。」),但第二個函數完全符合我的要求。 – Karlo