How to change ax.View in app desginer?

조회 수: 8 (최근 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 CenterFile Exchange에서 Develop 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