set() clears tiled chart layout plots when using to change axis scale.

4 次查看(过去 30 天)
I need to show these spectrograms with a logarithmic axis to show low frequency details in the spectra. Each time i use the set function it clears all other tiles/subplots.
figure
tcl = tiledlayout(1,3);
ax1=nexttile(tcl)
spectrogram(e2c.signal,e1b.windowLength(1),e1b.overlap(1),e1b.freqSteps,e1b.fs,'yaxis');
set(ax1,'YScale','Log')
ax2=nexttile(tcl);
spectrogram(e2c.y1,e1b.windowLength(1),e1b.overlap(1),e1b.freqSteps,e1b.fs,'yaxis');
set(ax2,'YScale','Log')
ax3=nexttile(tcl);
spectrogram(e2c.y2,e1b.windowLength(1),e1b.overlap(1),e1b.freqSteps,e1b.fs,'yaxis');
set(ax3,'YScale','Log')
the same issue occurs using subplot.
figure
ax1= subplot(1,3,1);
spectrogram(e2c.signal,e1b.windowLength(1),e1b.overlap(1),e1b.freqSteps,e1b.fs,'yaxis');
set(ax1,'YScale','Log');
title('1')
ax2=subplot(1,3,2);
spectrogram(e2c.y1,e1b.windowLength(1),e1b.overlap(1),e1b.freqSteps,e1b.fs,'yaxis');
set(ax2,'YScale','Log');
title('2')
ax3=subplot(1,3,3);
spectrogram(e2c.y2,e1b.windowLength(1),e1b.overlap(1),e1b.freqSteps,e1b.fs,'yaxis');
set(ax3,'YScale','Log');
title('3')
Can anyone suggest a better way to achieve a logarithmic axis on the spectrogram? I couldn't work out how to through the documentiation.

回答(1 个)

檮杌
檮杌 2023-9-27
I don't think I can reproduce your issue. Can you elaborate your issue by changing the sample code that I attach below?
%% Setting up a placeholder signal
N = 1024;
n = 0:N-1;
w0 = 2*pi/5;
x = sin(w0*n)+10*sin(2*w0*n);
%% Plot
figure
tcl = tiledlayout(1,3);
ax1=nexttile(tcl);
spectrogram(x,'yaxis');
set(ax1,'YScale','Log')
ax2=nexttile(tcl);
spectrogram(x,'yaxis');
set(ax2,'YScale','Log')
ax3=nexttile(tcl);
spectrogram(x,'yaxis');
set(ax3,'YScale','Log')
gcfPos = get(gcf,'position');
set(gcf, "Position", [gcfPos(1), gcfPos(2), 1200, 420])

类别

Help CenterFile Exchange 中查找有关 Spectral Estimation 的更多信息

产品


版本

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by