Effacer les filtres
Effacer les filtres

Plotting the content of huge matrix.

3 vues (au cours des 30 derniers jours)
Vira Roy
Vira Roy le 29 Avr 2022
Commenté : Vira Roy le 29 Avr 2022
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

Réponse acceptée

KSSV
KSSV le 29 Avr 2022
Modifié(e) : KSSV le 29 Avr 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]);
  1 commentaire
Vira Roy
Vira Roy le 29 Avr 2022
Thanks a ton. Really. Thank you so much.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Scatter Plots dans Help Center et File Exchange

Produits


Version

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by