How to do subplot using cwt()
Afficher commentaires plus anciens
Hey, I would like to plot a 3*3 subplots containing 9 figures from cwt(). However, I found it impossible to do that by simply doing
subplot(3,3,1)
cwt(data1)
subplot(3,3,2)
cwt(data2)
My guess is that we have to manually extract the cwt features and plot by ourselves under the subplot(). If yes, could anyone share a sample code for this part? If not, what should I do to draw such a subplot?
Thank you very much!
3 commentaires
Seems to work for me? Note that inputs must be vectors.
data1 = randi([0 255], 1, 128);
data2 = sort(data1);
subplot(3,3,1)
cwt(data1)
subplot(3,3,2)
cwt(data2)
Shengjie Gao
le 7 Mar 2021
Walter Roberson
le 7 Mar 2021
Ah, I see what you mean. The code specifically clears the current figure before plotting.
In some cases, the code creates two axes, but I have not figured out yet which cases that corresponds to.
The code is taking the wavelet transform information (what would normally be the first output) and abs() it, and effectively does an imagesc() of that.
Réponse acceptée
Plus de réponses (1)
Jeremy Scholze
le 27 Juil 2022
Modifié(e) : Jeremy Scholze
le 29 Juil 2022
Option 1: My Solution
Use
[cfs, frq] = cwt(data,Fs);
tms = (0:numel(data)-1)/Fs;
to calculate the wavelet transform and then do
imagesc(tms,frq,abs(C)); c = colorbar; c.Label.String = 'Magnitude';
axis tight; shading flat;
xlabel('Time (s)')
ylabel('Frequency (Hz)')
set(gca,'yscale','log')
to generate the plot. Your axes will be screwed up and you won't have the frequency bounds area greyed out but it'll work.
Option 2: MATLAB's Solution (less efficient)
openExample('wavelet/PlotCWTScalogramInSubplotExample')
They address this issue. Just run this in your command window ^
Edit: My method is apparently WAY more efficient than using the surface command in MATLAB's solution. Would recommend imagesc before surface. surface crashed my computer. The axis controls in MATLAB's solution will still work with imagesc.
Catégories
En savoir plus sur Continuous Wavelet Transforms dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

