'Plot bode inside UI axes of Matlab's app designer

I am creating a UI on app designer and I want to plot a bode in my UI.axes.

enter image description here

This figure contains two plots (magnitude, phase) and what I want to do is to plot each plot in different ui.axes.

I've managed to plot only the magnitude bode and the phase bode using the following code :

clc;
clear all;

num = [2];
den = [conv([1 1], conv([1 1], [1 1]))];
sys = tf(num, den);

[mag, phase, freq] = bode(sys, {0.1, 100});
bodemag(sys, freq)

h = bodeplot(sys, freq);
setoptions(h,'MagVisible','off');

This code gives me these two seperate plots :

enter image description here

enter image description here

I am trying to insert these plots in two different ui axes in my app.

Does any one have an idea or another approach on how to insert the plots ?

NB : I've tried the following :-

  • Writing the code direcly into the app designer but it creates a pop up instead
  • Using the plot(app.UiAxes, ...., ....) function but I can't seem to make it work


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source