Customize variables of spectogram

조회 수: 3 (최근 30일)
Victor Lee
Victor Lee 2019년 9월 18일
댓글: Bjorn Gustavsson 2021년 8월 4일
I am trying to create the spectogram with the respective variables. I understand that spectral functions only give back the variable of frequency and time. I guess I have to use imagec to customize my spectogram. However, I am unable to replicate the variables. Might need some help and guidance. My x-axis would be distance instead of time, while the y-axis is wavelength and the c-axis is dB(PSD).
This is my current output while my ideal output is the one below.
As attached is my code
RSADATA=xlsread('Nel20190802_MEAS35_displacement_results.xlsx');
dist=RSADATA(:,4);
rough=RSADATA(:,2);
rows = numel(dist);
sampdist = abs ((dist(rows) - dist(1)))/(rows-1);
totallength = dist(rows) -dist(1);
figure
plot(dist,rough);
ylabel ('Roughness (um)');
xlabel ('Distance (m)');
hold on
window = hamming(512);
noverlap=256; %number of overlaps
%window
nfft=1024; %size of the fft
fs_samp=1/sampdist; %i have my sampling frequency
roughamplitude = rough - mean(rough); %focus on fluctuation
pwelch(roughamplitude,[],[],[],fs_samp);
figure;
[S,F,T]=spectrogram(roughamplitude,window,noverlap,nfft,fs_samp,'yaxis');
imagesc('Distance',dist,'Frequency',F,'dB',S);
colorbar;
ax=gca;
ylim(ax,[0,40]);

답변 (1개)

Kshitij Chhabra
Kshitij Chhabra 2021년 8월 4일
From my understanding of the question, you want to modify the x, y, and z labels of the figure in the first image so that it looks like the one in the second image.
To achieve the same, you can modify the XLabel, YLabel and the ZLabel properties of the figure axes as follows:
ax=gca;
ax.XLabel.String="Distance(m)";
ax.YLabel.String="Wavelength(cm)";
ax.ZLabel.String="dB(PSD)";
For further information about the axes properties you can check here.
  댓글 수: 1
Bjorn Gustavsson
Bjorn Gustavsson 2021년 8월 4일
Shouldn't
ax.YLabel.String="Wavelength(cm)";
Rather be something like:
ax.YLabel.String="Wave-number (/m)";

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Graphics Performance에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by