Plotting the content of huge matrix.
4 views (last 30 days)
Show older comments
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
0 Comments
Accepted Answer
KSSV
on 29 Apr 2022
Edited: KSSV
on 29 Apr 2022
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]);
More Answers (0)
See Also
Categories
Find more on Axis Labels in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!