Linear scale to Log scale in CWT

23 views (last 30 days)
Raviteja
Raviteja on 23 Jul 2011
Answered: Robert U on 25 Sep 2019
Following this code..
>> y=[zeros(1,500) ones(1,500)];
>> cwt(y,1:128,'haar','plot');
>> colormap jet
>> colorbar
Here the plot is showing linear scale..
How to convert the linear scale to show log scale in CWT command..
I tried with this code
>>cwt(y,log10(1:128),'haar','plot');
But wavelet doesn't scale '0' scale so giving error like
**************************************
ERROR ...
--------------------------------------
cwt ---> Invalid Value for Scales !
**************************************
??? Error using ==> cwt at 74
Invalid Value for Scales !
So what is the solution to my problem ( conversion of linear to log scale ) ?

Answers (1)

Robert U
Robert U on 25 Sep 2019
Hi Raviteja,
the command cwt() allows to use the output matrix of the wavelet transform to produce your own plots. One possibility is to use the following way:
% attention: this is the 'old' command call, since version 2016b there is a 'new' command call
% assumption - the sampling frequency is 500 Hz
[wt,f] = cwt(y,1:128,'haar',500);
% create figure and axes
fh = figure;
ah = axes(fh);
% plot the absolute value of wavelet transform matrix (frequency vector may not contain '0 Hz'
imagesc(ah,1:size(wt,2),f,abs(wt))
colormap(fh,'pink') % change colormap to 'pink' to reproduce 'cwt'-look
ah.XScale = 'log'; % change scale of x axis to logarithmic
You can change almost all figure related parameters in that manner.
Kind regards,
Robert

Community Treasure Hunt

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

Start Hunting!