porque demora tanto cuando ploteo desde un livescript?

3 views (last 30 days)
tengo el siguiente problema, al intentar graficar cualquier figura desde un livescript, hasta un vector de solamente dos posiciones, tarda más de 15 minutos en si quiera dar respuesta, esto no le sucede utilizando scripts normales y el resto de funciones tampoco generan problemas, solamente sucede al plotear con cualquier funcion deade el livescript
  1 Comment
Ayush
Ayush on 18 Apr 2024
HI Juan, Can you share your code for which this 15 minute delay is being faced?

Sign in to comment.

Answers (1)

Sanchari
Sanchari on 10 Jul 2024
Edited: Sanchari on 10 Jul 2024
Hello Juan,
Responderé en inglés.
The issue being experienced with slow plotting in a MATLAB Live Script could be due to various factors, such as rendering overhead, large data sets, or specific configurations in the Live Editor. Here are several steps to diagnose and potentially resolve the issue:
1. Simplify the Plot: First, ensure that the issue is not related to the complexity of the plot. Try plotting a very simple figure to see if the problem persists.
% Simple plot example
x = [1, 2];
y = [3, 4];
figure;
plot(x, y);
It should give the following output:
2. Reduce Data Size: If plotting large data sets, try reducing the data size to see if it improves performance.
3. Update MATLAB: Ensure tht the latest version of MATLAB is being used, as performance improvements and bug fixes are regularly implemented.
4. Disable Live Script Output: Sometimes, the Live Script interface can slow down due to the rendering of outputs. Try disabling live outputs:
  • Navigate to Live Editor toolstrip > View tab > VIEW Section > deselect "Show Output Inline" button.
  • Alternatively, use the "drawnow" function to force MATLAB to render the plot immediately, which might help in some cases.
% Example with drawnow
x = [1, 2];
y = [3, 4];
figure;
plot(x, y);
drawnow;
5. Optimize Rendering Settings: Try adjusting rendering settings to improve performance. For example, switch from "OpenGL" to "Painters" or "ZBuffer" rendering.
% Example with different renderer
set(gcf, 'Renderer', 'painters');
x = [1, 2];
y = [3, 4];
figure;
plot(x, y);
6. Profile the Code: Use the MATLAB Profiler to identify bottlenecks in the code. This can help understand if the issue is due to plotting or other parts of the Live Script.
profile on;
% Your plotting code here
x = [1, 2];
y = [3, 4];
figure;
plot(x, y);
profile off;
profile viewer;
7. Clear Figures and Variables: Sometimes, accumulated figures and variables can slow down performance. Clear them before plotting.
close all;
clear variables;
x = [1, 2];
y = [3, 4];
figure;
plot(x, y);
Please refer the following links to get further knowledge on:
  1. drawnow function (MathWorks Documentation): https://www.mathworks.com/help/matlab/ref/drawnow.html?searchHighlight=drawnow&s_tid=srchtitle_support_results_1_drawnow
  2. Graphics performance (MathWorks Documentation): https://www.mathworks.com/help/matlab/graphics-performance.html
  3. Profiler (MathWorks Documentation): https://www.mathworks.com/help/matlab/ref/profile.html?searchHighlight=profiler&s_tid=srchtitle_support_results_1_profiler
Hope this helps!

Categories

Find more on Graphics Performance in Help Center and File Exchange

Tags

Products


Release

R2023b

Community Treasure Hunt

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

Start Hunting!