フィルターのクリア

How to change ax.View in app desginer?

11 ビュー (過去 30 日間)
Dominik Müller
Dominik Müller 2021 年 1 月 13 日
コメント済み: Dominik Müller 2021 年 1 月 13 日
Hi folks,
on my GUI im creating with App Designer I have an axes called app.UIAxes. And I have a drop down listing different viewing angles. What I want to do is the following:
By selecting a view I want to display on my axes, I enter a callback where I want to change app.UIAxes.View.
function changeView(app, event)
chosenView = app.DropDown.Value;
switch chosenView
case 1
view(app.UIAxes, [0 90]);
case 2
app.UIAxes.View = [30 30];
end
end
As you can see I tried two different ways to change the view of the axes but none of them is changing anything. after the callback the view stays the same as befor, no changes... Why? What am I doing wrong?

採用された回答

Dominik Müller
Dominik Müller 2021 年 1 月 13 日
Problem is solved:
If you enter items data it's stored as char. So therfor you have to cast from char to double or compare a string.
In my solution I cast a double out of char and then the switch-case works fine:
function changeView(app, event)
chosenView = str2double(app.DropDown.Value);
switch chosenView
case 1
view(app.UIAxes, [0 90]);
case 2
app.UIAxes.View = [30 30];
case 3
set(app.UIAxes, 'View', [90 0]);
end
end
All three cases can be used to change the view!
  2 件のコメント
Cris LaPierre
Cris LaPierre 2021 年 1 月 13 日
編集済み: Cris LaPierre 2021 年 1 月 13 日
The value of a dropdown is a character array.
The other option is to make your case expressions character arrays
chosenView = app.DropDown.Value;
switch chosenView
case '1'
view(app.UIAxes, [0 90]);
case '2'
app.UIAxes.View = [30 30];
case '3'
set(app.UIAxes, 'View', [90 0]);
end
Dominik Müller
Dominik Müller 2021 年 1 月 13 日
yep that is exactly what I meant by comparing a string ;-)

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

その他の回答 (0 件)

カテゴリ

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

製品


リリース

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by