필터 지우기
필터 지우기

How to get the current Axes.View after using rotate3d interaction in MATLAB appdesigner?

조회 수: 10 (최근 30일)
I'm using MATLAB R2021b appdesigner to design a UI . And my request is that I want to get the current axes view (azimuth & elevation data) after rotating my plot via rotate3d interation tool using my mouse. I have checked the related documentation and found that the following code worked well in the script form:
function demo_mbd2
% Listen to rotate events
surf(peaks);
h = rotate3d;
h.ActionPreCallback = @myprecallback;
h.ActionPostCallback = @mypostcallback;
h.Enable = 'on';
function myprecallback(obj,evd)
disp('A rotation is about to occur.');
function mypostcallback(obj,evd)
newView = round(evd.Axes.View);
msgbox(sprintf('The new view is [%d %d].',newView));
However, I have no idea of how to embed it in the appdesigner environment. For example, I'm not aware of the right form of callback function - it seems none of the following trail worked:
function mypostcallback(app, obj, evd)
function mypostcallback(obj, evd)
function mypostcallback(app, evd)
I haven't learned so much about call back functions yet I'm in desperate need of solving this specific problem. Could anyone lend me a hand? Are there any feasible ways to use the previous codes, or do we have any other solutions?
Huge thanks!!!

답변 (1개)

Kevin Holly
Kevin Holly 2022년 9월 1일
편집: Kevin Holly 2022년 9월 1일
Please see the attached app and scripts. I created a .m file for each callback function. Let me know if you have any questions.
Edit: Instead of pacing the message in the command window or message box, you could place it on a Label uicomponent.
app.Label.Text = "message";
  댓글 수: 3
文韬 王
文韬 王 2022년 9월 3일
Thanks a lot!!!
I got an inspiration from your example and later found that I only need to make a minor modification, that is to call it by `h.ActionPostCallback = @app.mypostcallback;` and define the function with the form of `function mypostcallback(app, obj, evd)` in the appdesigner scenario.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Interactive Control and Callbacks에 대해 자세히 알아보기

제품


릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by