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

8 visualizaciones (últimos 30 días)
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!!!

Respuestas (1)

Kevin Holly
Kevin Holly el 1 de Sept. de 2022
Editada: Kevin Holly el 1 de Sept. de 2022
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 comentarios
文韬 王
文韬 王 el 3 de Sept. de 2022
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.

Iniciar sesión para comentar.

Categorías

Más información sobre Interactive Control and Callbacks en Help Center y File Exchange.

Productos


Versión

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by