porque demora tanto cuando ploteo desde un livescript?

조회 수: 3 (최근 30일)
Juan Camilo Aguilar Coronado
Juan Camilo Aguilar Coronado 2024년 3월 19일
편집: Sanchari 2024년 7월 10일
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
Ayush
Ayush 2024년 4월 18일
HI Juan, Can you share your code for which this 15 minute delay is being faced?

댓글을 달려면 로그인하십시오.

답변 (1개)

Sanchari
Sanchari 2024년 7월 10일
편집: Sanchari 2024년 7월 10일
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!

카테고리

Help CenterFile Exchange에서 Graphics Performance에 대해 자세히 알아보기

태그

제품


릴리스

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by