필터 지우기
필터 지우기

Plotting the content of huge matrix.

조회 수: 3 (최근 30일)
Vira Roy
Vira Roy 2022년 4월 29일
댓글: Vira Roy 2022년 4월 29일
Problem: I have a huge 449x10001 dimension matrix and want to make a scatter plot from that. While for loop works good enough for smaller size, plotting this huge matrix is extremely time and resource consuming. (I am aware this is a bad way of coding the problem, sorry)
I have attached a smaller version of the huge matrix here and shown my code below. This code here with matrix dimension 449x50 takes 31 seconds to do the plot. Is there a better way without using a for loop to access the entries and make the plot.
It would be extremely helpful if you can guide someway here. Thank you.
My code(attached are big_mat.mat and yaxis.mat)
x = linspace(1,449,449);
y_ = matfile('yaxis.mat');
spectral_wt = matfile('big_mat.mat');
S_wt = spectral_wt.spectral_wt;
y = y_.y;
for i = 1 : 50
scatter(x,y(:,i),[],S_wt(:,i),'filled')
hold on
colormap default
colorbar
ylabel('Energy')
xticks([0 64 128 192 256 320 384 448])
xticklabels({'\Gamma','M1','M2','M3','X1','X2','X3','R'})
xline([64,128,192,256,320,384,448]);
end

채택된 답변

KSSV
KSSV 2022년 4월 29일
편집: KSSV 2022년 4월 29일
You need not to use scatter in a loop. You can do all this at one go using scatter or you can use pcolor as shown below.
x = linspace(1,449,449);
y_ = matfile('yaxis.mat');
spectral_wt = matfile('big_mat.mat');
S_wt = spectral_wt.spectral_wt;
y = y_.y;
X = repmat(x,size(y,2),1)' ;
Y = y ;
Z = S_wt ;
pcolor(X,Y,Z)
shading interp
colormap default
colorbar
ylabel('Energy')
xticks([0 64 128 192 256 320 384 448])
xticklabels({'\Gamma','M1','M2','M3','X1','X2','X3','R'})
xline([64,128,192,256,320,384,448]);
  댓글 수: 1
Vira Roy
Vira Roy 2022년 4월 29일
Thanks a ton. Really. Thank you so much.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Scatter Plots에 대해 자세히 알아보기

제품


릴리스

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by