The plotting freezes and does not render any more data

4 次查看(过去 30 天)
Hello,
version of matlab: 2020a
describe problem: I have created an application in the app designer, where I collect data, which I then transfer to the simulink, where I perform system simulation. Then I draw this data into the plot. I get all the data from the simulink, but when drawing to the plot, it happens that the drawing freezes and does not continue. For example, I can close the application or click on the buttons, but the graph is not drawn. Sometimes it also happens that I can't restart the application using the RUN button and I have to restart the whole matlab.
I have another system in the application that is drawn into the plot without a problem.
Demonstration of what the plot will gradually display. The data in the simulink is across the entire timeline. Only 1/6 of the data is plotted here, for example.
cla(app.O_Z_N_K_Animace_Nadrze
sim = sim('Simulink_al');
number_of_values = length(sim.reg{1}.Values.Data);
hold(app.Plot,'on')
plot(app.Plot,sim.reg{1}.Values.Time(1:number_of_values),sim.reg{1}.Values.Data(1:num_of_values), 'b--', 'LineWidth', 1);
plot_vel = plot(app.Plot,sim.reg{2}.Values.Time(1),sim.reg{2}.Values.Data(1), 'LineWidth', 2);
hold(app.E_V_M_Graficke_Prubehy,'off')
for r = 1:number_of_values
hold(app.Plot,'on')
set(graf_regulovana_velicina,'Ydata',sim.reg{2}.Values.Data(1:r),'Xdata',sim.reg{2}.Values.Time(1:r));
hold(app.Plot,'off')
if (r == number_of_values)
app.Button_Start.Enable = true;
end
pause(0.02)
end
I have about 2000 lines of code in this application, but this part of the code shown here is executed when the rendering freezes.
As I mentioned earlier, I did not have such problems, but now there are various freezes, whether rendering the graph or the entire application. Where the solution is only a complete restart of the matlab.
Sometimes I get this error back. But it's not always the same. Sometimes I don't even get this error message.
Warning: An error occurred while drawing the scene: Could not find node in peer tree during
replaceChild
Warning: An error occurred while drawing the scene: Could not find node in peer tree during
reparentChildren
If I have the content of this variable listed, for example. So I got the complete data from the simulink. So the program has complete data, but it only plots a part and freezes.
disp(sim.reg{2}.Values.Data) OR disp(sim.reg{2}.Values.Time)
Thank you very much for any help
  1 个评论
Rik
Rik 2022-4-24
I don't see an indication of why your plot would freeze. You don't create thousands of graphics objects in your loop, which is a common cause of issues.
With your syntax you don't need the calls to hold, since you directly change object properties. I don't think that will have any effect in your code.

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Vehicle Scenarios 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by