How could I speed up this loop made to plot using the pcolor function?

5 ビュー (過去 30 日間)
Luca Ribba Esteva
Luca Ribba Esteva 2021 年 7 月 9 日
編集済み: Ilias Psilakis 2023 年 12 月 19 日
Hi, i am trying to plot by pcolor a matrix called H, of size 7x7x20001, where 20001 represents a temporary dimension. My idea is to be able to see the evolution of the graph in each step, that is why I have used the drawnow. The problem is that the complete realization of the loop is slow, therefore, the speed of evolution of the plotted graph is also slow. By the way, I am not sure that the use of the pcolor function in itself is fast or not, therefore I do not know if the origin of my problem is really in how I did the loop or in how the pcolor function works.
set(groot,'defaultAxesFontSize',12)
for k=1:length(r)
pcolor(H(:,:,k));
colorbar;
xlabel('Dirección x');
ylabel('Dirección y');
colormap(jet);
caxis([23 100]);
shading interp;
axis equal tight;
drawnow
end

採用された回答

KSSV
KSSV 2021 年 7 月 9 日
編集済み: KSSV 2021 年 7 月 9 日
A = rand(7,7,20001) ;
[m,n,p] = size(A) ;
[X,Y] = meshgrid(1:n,1:m) ;
set(groot,'defaultAxesFontSize',12)
h = pcolor(A(:,:,1)) ;
colorbar;
xlabel('Dirección x');
ylabel('Dirección y');
colormap(jet);
% caxis([23 100]);
shading interp;
axis equal tight;
for i = 1:p
set(h,'CData',A(:,:,i)) ;
title(num2str(i))
drawnow
end
  2 件のコメント
Luca Ribba Esteva
Luca Ribba Esteva 2021 年 7 月 9 日
Wow bro, with your code its a lot more faster, you are the mvp, thx you very much :)
Ilias Psilakis
Ilias Psilakis 2023 年 12 月 19 日
編集済み: Ilias Psilakis 2023 年 12 月 19 日
How possible would be to be able to navigate through the 'frames', meaning to have all the frames saved in the same figure with the possibility to go backwards and forward?

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeGraphics Performance についてさらに検索

製品


リリース

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by