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 件のコメント
Ayush
2024 年 4 月 18 日
HI Juan, Can you share your code for which this 15 minute delay is being faced?
回答 (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!