How to get the current Axes.View after using rotate3d interaction in MATLAB appdesigner?
2 views (last 30 days)
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:
% Listen to rotate events
h = rotate3d;
h.ActionPreCallback = @myprecallback;
h.ActionPostCallback = @mypostcallback;
h.Enable = 'on';
disp('A rotation is about to occur.');
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?
Kevin Holly on 1 Sep 2022
Edited: Kevin Holly on 1 Sep 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";