How to do subplot using cwt()
조회 수: 63(최근 30일)
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
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!
Monisha Nalluru 2021년 3월 11일
cwt() would support subplots only with complex valued input signals that will plot the analytic and anti-analytic parts into seperate subplot.
In all other case, the output of cwt can be used with surface,pcolor or image to produce similar plot
As an example
[wt1,f1] = cwt(mtlb,'bump',Fs);
[wt2,f2] = cwt(mtlb,Fs);
Example cwt supporting subplots for complex valued iput ,
plot(npg2006.cx); hold on; grid on;
xlabel('Eastward Displacement (km)');
ylabel('Northward Displacement (km)');
'markerfacecolor',[1 0 0 ]);
Hope this helps!
Jeremy Scholze 2022년 7월 27일
편집: Jeremy Scholze 2022년 7월 29일
Option 1: My Solution
[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;
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)
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.