Plotting performance reduced in APP

1 回表示 (過去 30 日間)
Luca Vacca
Luca Vacca 2020 年 1 月 14 日
編集済み: Veronica Taurino 2022 年 5 月 2 日
I designed a GUI with Matlab 2019a App Designer tool for visualization of 3D segments and automatic labelling. The figure below shows an example of app.UIAxes component and then the script in my app is presented.
% when a push button is pressed
cla(app.UIAxes) % app.UIAxes contains other data to be cleared from the current figure
for i=1:half
% first point of the i-segment is stored in SEGMENTS(i,1:3)
% last point of the i-segment is stored in SEGMENTS(i+half,1:3)
% plot the current segment
line(app.UIAxes,[SEGMENTS(i,1),SEGMENTS(i+half,1)],...
[SEGMENTS(i,2),SEGMENTS(i+half,2)],...
[SEGMENTS(i,3),SEGMENTS(i+half,3)],'Color','k')
% label the current segment on its midpoint
x_mid=mean([SEGMENTS(i,1),SEGMENTS(i+half,1)]);
y_mid=mean([SEGMENTS(i,2),SEGMENTS(i+half,2)]);
z_mid=mean([SEGMENTS(i,3),SEGMENTS(i+half,3)]);
text(app.UIAxes,x_mid,y_mid,z_mid,num2str(i),'Color','b',...
'FontSize',12,'FontWeight','bold'), hold(app.UIAxes,'on');
end
hold(app.UIAxes,'off');
As stated in https://it.mathworks.com/matlabcentral/answers/252979-increase-the-plotting-performance-in-the-matlab-level-drawmode-optimizing-rendering-down-sampling, I used the function line instead of plot3. However, when interacting by 3D rotation, the figure in my app is much slower than the same plotted through Matlab command window (also with few segments, but it should work with hundreds of segments). In particular, I found that the lag is introduced when adding text labels, and this lag (increased in time duration) occurs on other PCs.
Any suggestion to overcome this issue and improve usability of my app?
Thanks in advance
  2 件のコメント
Mohammad Sami
Mohammad Sami 2020 年 1 月 17 日
You can try and avoid the for loop. That can make the plotting faster. Something like this might work
% half = floor(size(SEGMENTS,1)/2);
idx = 1:half;
sgx = [SEGMENTS(idx,1),SEGMENTS(idx+half,1)]';
sgy = [SEGMENTS(idx,2),SEGMENTS(idx+half,2)]';
sgz = [SEGMENTS(idx,3),SEGMENTS(idx+half,3)]';
line(app.UIAxes,sgx,sgy,sgz,'Color','k');
x_mid=mean(sgx);
y_mid=mean(sgy);
z_mid=mean(sgz);
text(app.UIAxes,x_mid,y_mid,z_mid,string(idx),'Color','b',...
'FontSize',12,'FontWeight','bold');
Luca Vacca
Luca Vacca 2020 年 1 月 17 日
Thank you for your suggestion. However no improvements took place even if your code is a ligther version of mine, so I don't think it is a code-problem. Could this issue be related to the location where varibles are stored? Is it different for Matlab and user-designed app?

サインインしてコメントする。

採用された回答

Yair Altman
Yair Altman 2020 年 1 月 20 日
App Designer creates an HTML/JavaScript-based webpages (uifigures), which are noticably slower than the Java-based figures that are created when you run your script from the Matlab Command Window. Unfortunately, there is not much that you can do to improve uifigure performance except wait for newer Matlab releases.
However, if the nifty UI widgets that you can create with App Designer are not very important for you, you can create your graph in a standard (i.e. Java-based) figure, which will be much faster. In other words, simply copy the script that you ran in the Command Window into an m-file and then run that m-file as needed.
  2 件のコメント
Adam Gogacz
Adam Gogacz 2020 年 10 月 2 日
Yair, 2020b is no better, still subpar performance. Do you have any ideas what's causing the uifigures to be so sluggish?
Veronica Taurino
Veronica Taurino 2022 年 5 月 2 日
編集済み: Veronica Taurino 2022 年 5 月 2 日
2021b does not seem any better...

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMigrate GUIDE Apps についてさらに検索

製品


リリース

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by