How to do subplot using cwt()
Mostrar comentarios más antiguos
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 comentarios
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
el 7 de Mzo. de 2021
Walter Roberson
el 7 de Mzo. de 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.
Respuesta aceptada
Más respuestas (1)
Jeremy Scholze
el 27 de Jul. de 2022
Editada: Jeremy Scholze
el 29 de Jul. de 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.
Categorías
Más información sobre Continuous Wavelet Transforms en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

