Azzera filtri
Azzera filtri

How to change ax.View in app desginer?

11 visualizzazioni (ultimi 30 giorni)
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?

Risposta accettata

Dominik Müller
Dominik Müller il 13 Gen 2021
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 Commenti
Cris LaPierre
Cris LaPierre il 13 Gen 2021
Modificato: Cris LaPierre il 13 Gen 2021
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 il 13 Gen 2021
yep that is exactly what I meant by comparing a string ;-)

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Develop Apps Using App Designer in Help Center e File Exchange

Prodotti


Release

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by