App desiner GUI crashes when use scatter3

9 visualizzazioni (ultimi 30 giorni)
Davide P
Davide P il 10 Feb 2021
Commentato: Davide P il 25 Feb 2021
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

Risposte (2)

Adam Danz
Adam Danz il 10 Feb 2021
Modificato: Adam Danz il 11 Feb 2021
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 Commenti
Veronica Taurino
Veronica Taurino il 25 Feb 2021
Modificato: Veronica Taurino il 25 Feb 2021
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
Davide P il 25 Feb 2021
Ok, no problem. I had to do some GUI with Matlab and actually there are often problems. We hope they improve.

Accedi per commentare.


Davide P
Davide P il 18 Feb 2021
I have updates from support: has been confirmed as a bug currently present
Cause of the problem: the problem is related to the render engine "It is an internal memory issue when interacting with Chromium windows specifically, which is why the behavior is observable with Apps and UIFigures but not with the standard Java based figure."
I immediately say that the definitive solution does not yet exist. It's only partially solved in the 2021a prerelease.
There are possible wokarounds. I put them here because maybe someone could be useful for actual release.
  • In 2020a and 2020b versions: you have to try to switch to an alternative render engine, so depending on the one set, you have to try to use one of these two commands:
> from the Windows Command Prompt using:
matlab -softwareopenglmesa
> executing the following in the MATLAB Command Window:
>> opengl software
I tried with "matlab -softwareopenglmesa" and I was able to visualize the points within UIAxes. However, for me the solution is not optimal because in any case there is a heavy slowdown in the rotation of the points and above all it is an impractical solution because it depends on the PC on which the App is running.
  • In the 2021a preprelease version the problem is mitigated (but not completely solved) because it uses a different version of Chromium. Use in that case:
s = scatter3 (app.UIAxes_GL_3D, ROI_coord (:, 1), ROI_coord (:, 2), ROI_coord (:, 3), 1, color_matrix, 'PickableParts', 'none');
PickableParts was introduced in 2021 and works to mitigate the problem.
Obviously I was told that the development team will look for a definitive solution that will be included in the code as soon as it is ready.

Categorie

Scopri di più su Environment and Settings in Help Center e File Exchange

Prodotti


Release

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by