フィルターのクリア

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

10 ビュー (過去 30 日間)
文韬 王
文韬 王 2022 年 9 月 1 日
コメント済み: 文韬 王 2022 年 9 月 3 日
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 Center および File ExchangeInteractive 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