How can we assign more than one plot to the same place on guı?

1 回表示 (過去 30 日間)
Serhat Sayim
Serhat Sayim 2021 年 1 月 9 日
コメント済み: Serhat Sayim 2021 年 1 月 9 日
I designed a guı on matlab app designer. I want to put the lines that are in right 'Figüre 1' on the plot that is in left side but I could not do it.
load sampleWheezeData.mat
ses=structWheeze(2,1).SoundData;
WS_new_array=structWheeze(2,1).Properties.WS_new;
WE_new_array=structWheeze(2,1).Properties.WE_new;
x = linspace(0, 144000 , 144000);
plot(app.UIAxes2,x,ses)
hold on
plot(x(WS_new_array*[1 1]).',(ones(size(WS_new_array,1),2).*ylim).', '-g', 'LineWidth',2);
plot(x(WE_new_array*[1 1]).', (ones(size(WE_new_array,1),2).*ylim).', '-r', 'LineWidth',2);
hold off
grid
When I press the plot button it should look like this on the app but codes that I wrote here only shows the blue parts not the lines. How can I do it? Thank you.

回答 (1 件)

Cris LaPierre
Cris LaPierre 2021 年 1 月 9 日
編集済み: Cris LaPierre 2021 年 1 月 9 日
You need to specify the axes to hold and to plot to.
plot(app.UIAxes2,x,ses)
hold(app.UIAxes2,'on')
plot(app.UIAxes2,x(WS_new_array*[1 1]).',(ones(size(WS_new_array,1),2).*ylim).', '-g', 'LineWidth',2);
plot(app.UIAxes2,x(WE_new_array*[1 1]).', (ones(size(WE_new_array,1),2).*ylim).', '-r', 'LineWidth',2);
hold(app.UIAxes2,'off ')
grid(app.UIAxes2,'on')
  3 件のコメント
Cris LaPierre
Cris LaPierre 2021 年 1 月 9 日
Ah, ylim is your issue. You need to specify the target axes for that function as well.
ylim(app.UIAxes2)
Basically, in an app, you always have to tell it the axes to use.
Serhat Sayim
Serhat Sayim 2021 年 1 月 9 日
I got it. Thank you for your answers. Have a nice weekend.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeDevelop Apps Using App Designer についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by