Plotting the content of huge matrix.

3 次查看(过去 30 天)
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]);

更多回答(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