How can insert a 'bodeplot' in an axes object of AppDesigner.

13 次查看(过去 30 天)
Hi,
I have an application developed in the past (Matlab 2013b) with several chained GUI´s sharing information. The application was build to aid the engineers of the control section during the tasks of tunning some control loops used at the company. Now, I am migrating the application to Matlab 2020a with AppDesigner, and I have found a problem with the calls to the Matlab function 'bodeplot'.
"Error using DynamicSystem/bodeplot (line 113)
Functionality not supported with figures created with the uifigure function. For more information, see Graphics Support in App Designer."
In my application, the calls to the function bodeplot, always have a signature similar to this:
bodeplot(handle_axis_n, sys)
Where 'handle_axis_n' is the handle of the axes object where the bode diagram should be plotted, and 'sys' the LTI object.
And are coherent with the expected signature documented in the bodeplot manual: 'https://es.mathworks.com/help/control/ref/bodeplot.html'
If the function bodeplot is not supported with graphic containers of App Designer, How can I insert a bode plot in an application of App Designer?
Thanks in advance.

回答(1 个)

Divyajyoti Nayak
Divyajyoti Nayak 2025-1-27,10:26
The support for ‘UIAxes’ handles in ‘bodeplot’ for App Designer was added from R2020b. I would suggest to update MATLAB to at least R2020b to fix the issue. If updating is not possible, then the following workaround can be used:
Add a panel in the design view and the following code can be used to programmatically create a bodeplot:
app.Panel.AutoResizeChildren = 'off';
ax1 = subplot(2,1,1,'Parent',app.Panel);
ax2 = subplot(2,1,2,'Parent',app.Panel);
%Sample Transfer Function
H = tf([1 0.1 7.5],[1 0.12 9 0 0]);
[mag,phase,wout] = bode(H);
semilogx(ax1,wout,20*log10(squeeze(mag)));
title(ax1,"Bode Diagram");
ylabel(ax1,"Magnitude (dB)");
semilogx(ax2,wout,squeeze(phase));
ylabel(ax2,"Phase (deg)");
xlabel(ax2,"Frequency (rad/s)");
The ‘bode’ function is used to get the data for the plot, here’s some documentation for it:
Notice that 'bode' command does not have the auxiliary methods 'getoptions and 'setoptions'. Therefore customizations to the plot should be implemented manually (e.g. unit changes).

类别

Help CenterFile Exchange 中查找有关 Classical Control Design 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by