Units of kHz in frequency plots
조회 수: 25 (최근 30일)
이전 댓글 표시
When calling functions like pwelch, spectrogram or poctave with no function outputs, MATLAB conveniently provides a plot. That saves me from a lot of code (and potential bugs).
However, the following code (from poctave, I presume something similar occurs elsewhere) makes the plots less intuitive to my eyes, and often cause me to just define the plot from ground up.
% Determine engineering units
[~, scaleFactor, unitsStr] = signal.internal.utilities.getFrequencyEngUnits(CF(end));
...
elseif (value < 1000)
scaleFactor = 1;
unitsStr = 'Hz';
elseif (value < 1000 * 1000)
scaleFactor = 1 / 1000;
unitsStr = 'kHz';
I prefer the x-axis to read:
[3, 8, 20, 50, 126, 316, 794, 1995, 5012, 12589] [Hz]
Rather than:
[0.003, 0.008, 0.020, 0.050, 0.126, 0.316, 0.794, 1.995, 5.012, 12.589] [kHz]
I see that a similar question was asked here, where it is suggested to modify xticks after the fact, which is somewhat more complicated with the use of cathegorical for xticks:
My request would be for a string option ala:
spectrogram(x, N, N/2, N, 48e3, 'Yaxis', 'UseSIBaseUnits')
댓글 수: 0
답변 (1개)
Giggs B.
2021년 8월 3일
I know its late to answer, but for someone who faces the similar problem, try this:
set(gca,'XTick',[0.003, 0.008, 0.020, 0.050, 0.126, 0.316, 0.794, 1.995, 5.012, 12.589])
set(gca,'XTickLabel',[3, 8, 20, 50, 126, 316, 794, 1995, 5012, 12589])
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Time-Frequency Analysis에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!