App desiner GUI crashes when use scatter3
이전 댓글 표시
Hi,
i have a problem with app designer and scatter3.
When I use scatter3 specifying the color for each point, the app crashes without giving any errors.
This is the line that causes the app to unexpectedly close:
scatter3 (app.UIAxes_GL_3D, ROI_coord(:, 1), ROI_coord(: 2), ROI_coord(:, 3), 1, color_matrix);
ROI_coord is a matrix of 22375x3 double, color_matrix is a matrix of 22375x3 double (with values between 0 and 1), UIAxes_GL_3D is the app axis.
I tried to use fewer points and in that case everything works fine.
I use Matlab version 2020a.
Why does this happen?
Thank you,
Davide
답변 (2개)
I've reproduced the problem using Matlab Online with the code below (commented-out to discourage people from trying it). Matlab Online crashes and throws an error in Chrome: Error code: Out of Memory
But this shouldn't cause Matlab to crash. It should just throw an error. I encourage you to report the problem: Contact Us - MATLAB & Simulink
% This will crash Matlab (Matlab Online 2020b)
% ROI_coord = rand(22375,3);
% color_matrix = rand(22375,3);
%
% app.UIAxes_GL_3D = uiaxes();
% scatter3 (app.UIAxes_GL_3D, ROI_coord(:, 1), ROI_coord(:, 2), ROI_coord(:, 3), 1, color_matrix);
There may be other ways to plot your data that don't involve storing 22375 graphics objects. Without knowing more about the intended visualization, it's tough to make suggestions.
Update I
Without the color_matrix, the scatter plot is created without a problem.
Update II
I traced the problem in scatter3() and it crashes when the CData property is set (the color matrix). Even if you set the CData after the plot is generated, it will still crash (see below).
ROI_coord = rand(22375,3);
color_matrix = rand(22375,3);
app.UIAxes_GL_3D = uiaxes();
h = scatter3 (app.UIAxes_GL_3D, ROI_coord(:, 1), ROI_coord(:, 2), ROI_coord(:, 3), 1);
% crash here:
% h.CData = color_matrix;
Update III
None of these problems happen with Matlab r2020b (update 4) on Microsoft Windows 10.
Workaround ideas
If there is color grouping, use indexing to plot each group separately using plot3() or scatter3(). dr
You could try using color indexing rather than defining the RGB value matrix. That's covered the documentation.
If each point varies in color, you might be able to visualize the data using another form such as a controur or surface. Perhaps you could reduce the density of data and plot custers using kmeans or another clustering method.
댓글 수: 16
Davide P
2021년 2월 10일
Adam Danz
2021년 2월 10일
I was just messing around with it further and also found that removing color_matrix eliminated the crash.
Do you have groups of colors or are each point a completely different color?
If you have groups of colors you can plot each group separately which will likely solve the problem.
Adam Danz
2021년 2월 10일
I've updated my answer again.
You might locate your crash logs to look into reason for the crash.
Adam Danz
2021년 2월 10일
> once visible on the app axis, it is practically unusable: it must be slowed down so much that it is almost impossible to rotate
> they are the projection of a 2D image on 3D points
Perhaps you could visualize the 3D data with scatter3() using a single color and then visualize the 2D image using imagesc() or contourf() plotted on the same axis, under the scatter points. Here are some demos of similar approaches
- imagesc + quiver
- imagesc + contour with separate colormaps
- contour + quiver (see comments too)
- contour + scatter
> What I don't understand is why none of this happens if a figure is created instead of using the app.
Not sure what this means. I tried the reproducible demo in my answer using figure() and axes() instead of uifigure/uiaxes and the problem persists.
> I'll try to see if anything comes out of the logs, but I have my doubts
I'd be intertested in what you find. I've been testing it on Matlab Online and haven't looked into whether those logs are available online. Either way, I think it's something to be reported to tech support.
Adam Danz
2021년 2월 10일
btw, I tried using color indexing and it crashes as well.
% This will crash Matlab (Matlab Online 2020b)
% ROI_coord = rand(22375,3);
% color_matrix = randi(5,22375,1); % <--- color index
%
% app.UIAxes_GL_3D = uiaxes();
% scatter3 (app.UIAxes_GL_3D, ROI_coord(:, 1), ROI_coord(:, 2), ROI_coord(:, 3), 1, color_matrix);
Davide P
2021년 2월 11일
When I run the example you gave using regular figures using Matlab Online which uses release r2020b, it definitely crashes:
ROI_coord = rand(22375,3);
color_matrix = rand(22375,3);
figure();
ax1=axes();
h = scatter3 (ax1, ROI_coord(:, 1), ROI_coord(:, 2), ROI_coord(:, 3), 1,color_matrix );

I can't test it on my local software because I'm using it for multiple projects at the moment. I see you're using r2020a so the different may be due to the release or the system (Matlab Online uses Linux).
Have you reported this to Tech Support?
Davide P
2021년 2월 11일
Adam Danz
2021년 2월 11일
I've tested in with r2020b (update 4) Microsoft Windows 10 and there are no problems with using figure or uifigure/uiaxes.
So, here's what we know:
figure/axes uifigure/uiaxes
2020a: OK crash
2020b OK OK
2020b online: crash crash
Adam Danz
2021년 2월 11일
Just out of curiosity in your report to tech support did you point to this conversation or tell them about the problems with Matlab online? They should know about that.
Davide P
2021년 2월 12일
Veronica Taurino
2021년 2월 25일
I can't make it work on 2020b either.
Davide P
2021년 2월 25일
Veronica Taurino
2021년 2월 25일
편집: Veronica Taurino
2021년 2월 25일
Hi Davide, I already read your answer, thank you. My intention by replying was to point out that one more person is hoping to fix it . I don't know how it works on Mathworks community, I thought the more feedback they have, the sooner they decide to work on it (more people asking = feature greatly required = priority for the team).
[I am working on point cloud on GUI, both pcshow and scatter3 have trouble, I am going to try plot3 but I already know I will have other issue (due to my specific workflow I mean). Thank you, bye]
Davide P
2021년 2월 25일
카테고리
도움말 센터 및 File Exchange에서 Develop Apps Using App Designer에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

