Set a log XScale to an imagesc axis

9 views (last 30 days)
Arnaud Guibert
Arnaud Guibert on 25 Sep 2019
Answered: Arnaud Guibert on 20 Jan 2020
Hi everybody,
I would like to solve a viewing problem I get with the imagesc function. The aim of my work is to realize a "homemade" spectrogram (lofargram) of a sampled signal. My method is quite typical: realizing DFT on windowed parts of the signal which can partially recover themselves. Finally I get a matrix of hundreds rows (time) and dozens thousands columns (frequencies). I would like to picture it to make a visual analysis of the matrix and get particular frequencies. A typical way to anayse this kind of spectrogram is to set the frequency scale into the logarithmic form, which seems to have a problem on the Matlab 2018b version.
Let's create a matrix with a highlighted column:
M = zeros(100,100);
M(:,50) = 1;
X = linspace(0.1,10,100);
Y = linspace(1,100,100);
Now we can try to observe this matrix using the imagesc function with both lin and log Xcale:
figure
imagesc(X,Y,M), colorbar
figure
imagesc(X,Y,M), colorbar
set(gca,'Xscale','log')
On the first picture I get a highlighted column at X = 5 (which is ok) and on the second one at X = 0.6903. Let's now try with the surf function:
figure
surf(X,Y,M), colorbar
view(0,90)
figure
surf(X,Y,M), colorbar
view(0,90)
set(gca,'XScale','log')
Here on both pictures I get the highlighted column at X = 5 which is the right answer.
The problem is that I cannot use the "surf" function for my usual matrixes as the scale is too important.
Another funny fact is that you can try to picture that kind of matrix with the dedicated Matlab spectrogram function. But if you try to change the Xscale with the property editor, the figure is then whitened...
Thanks in advance for your advices and remarks on my topic,
Best regards,
Arnaud

Answers (1)

Arnaud Guibert
Arnaud Guibert on 20 Jan 2020
Up

Categories

Find more on Graphics Performance in Help Center and File Exchange

Products


Release

R2018b

Community Treasure Hunt

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

Start Hunting!