porque demora tanto cuando ploteo desde un livescript?
조회 수: 3 (최근 30일)
이전 댓글 표시
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
답변 (1개)
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:
- drawnow function (MathWorks Documentation): https://www.mathworks.com/help/matlab/ref/drawnow.html?searchHighlight=drawnow&s_tid=srchtitle_support_results_1_drawnow
- Graphics performance (MathWorks Documentation): https://www.mathworks.com/help/matlab/graphics-performance.html
- Profiler (MathWorks Documentation): https://www.mathworks.com/help/matlab/ref/profile.html?searchHighlight=profiler&s_tid=srchtitle_support_results_1_profiler
Hope this helps!
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Graphics Performance에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!