필터 지우기
필터 지우기

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

조회 수: 7 (최근 30일)
Alexander
Alexander 2023년 9월 26일
답변: 檮杌 2023년 9월 27일
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에서 Annotations에 대해 자세히 알아보기

제품


릴리스

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by