AppDesigner plot on specific UIAxes from list

14 ビュー (過去 30 日間)
giuggi giuggi
giuggi giuggi 2022 年 7 月 22 日
コメント済み: Kevin Holly 2022 年 7 月 25 日
I have an app with 10 UIAxes disposed on different pages. I want to know if there is a way to use a single function to produce plot on different UIAxes. For example here i have a list of all my UIAxes from 1 to 10 and i want to use a list to specify on what UIAxes i want to plot my data (datax,datay).
uiaxes_list = {'UIAxes1','UIAxes2','UIAxes3','...','UIAxes10'};
for i = 1:10
p = plot(uiaxes_list{1,i},datax,datay);
end
if I use something like that i got the error "invalid first data argument".
now i have a code like that but i want to improve it to add more functions.
if i == 1
p = plot(UIAxes1,datax,datay);
elseif i == 2
p = plot(UIAxes2,datax,datay);
elseif i == 3
p = plot(UIAxes3,datax,datay);
...
end
thanks.

回答 (1 件)

Kevin Holly
Kevin Holly 2022 年 7 月 22 日
編集済み: Kevin Holly 2022 年 7 月 22 日
If you have a set number of UIAxes, you could use a switch case in a function as such:
function foo(ChosenAxes,datax,datay)
switch ChosenAxes
case 'UIAxes1'
p = plot(app.UIAxes1,datax,datay);
case 'UIAxes2'
p = plot(app.UIAxes2,datax,datay);
case 'UIAxes3'
p = plot(app.UIAxes3,datax,datay);
end
end
  2 件のコメント
giuggi giuggi
giuggi giuggi 2022 年 7 月 24 日
thanks for your answer but this is similar to my script. I need a script that automatically changes the UIAxes target from the list. For example if i want to change a property, for example the linestyle of all plot, I want to avoid writing:
p1 = plot(app.UIAxes1,datax,datay);
app.p1.LineStyle = '--';
p2 = plot(app.UIAxes2,datax,datay);
app.p2.LineStyle = '--';
...
p10 = plot(UIAxes10,datax,datay);
app.p10.LineStyle = '--';
and instead use a for loop to automatically change all plots linestyle.
Kevin Holly
Kevin Holly 2022 年 7 月 25 日
Please see the app attached and let me know if you have any more questions.

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

カテゴリ

Help Center および File ExchangeStartup and Shutdown についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by