Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/matlab/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/maven/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Matlab 如何绘制光谱图函数的结果?_Matlab_Spectrogram - Fatal编程技术网

Matlab 如何绘制光谱图函数的结果?

Matlab 如何绘制光谱图函数的结果?,matlab,spectrogram,Matlab,Spectrogram,在我的图中,我有两个轴,第一个是信号的时间序列,第二个是信号的ifft。我想添加第三个轴,其中包含信号的频谱图。我该怎么做 % Create the raw signal fs = 40; t = 0:( 1/fs ):4; y1 = [ sin( 2*pi*5*t( t<=2 ) ), sin( 2*pi*10*t( t>2 ) ) ]; % Compute the ifft of the signal Fy1 = abs(ifft(y1)); N = numel(t); idx

在我的图中,我有两个轴,第一个是信号的时间序列,第二个是信号的
ifft
。我想添加第三个轴,其中包含信号的频谱图。我该怎么做

% Create the raw signal
fs = 40;
t = 0:( 1/fs ):4;
y1 = [ sin( 2*pi*5*t( t<=2 ) ), sin( 2*pi*10*t( t>2 ) ) ];

% Compute the ifft of the signal
Fy1 = abs(ifft(y1));
N = numel(t);
idx = 1:numel(Fy1) / 2;
f = fs*(0:(N-1)) / N;

% Plot the raw signal as a time series
subplot(311);
plot(t,y1,'k');
xlabel('Time (s)');
ylabel('Amplitude');

% Plot the spectrum of the signal
subplot(312);
plot(f(idx),2*Fy1(idx),'k')
xlabel('Frequency (cycles/second)');
ylabel('Amplitude');
%创建原始信号
fs=40;
t=0:(1/fs):4;
y1=[sin(2*pi*5*t(t2))];
%计算信号的ifft
Fy1=abs(ifft(y1));
N=努美尔(t);
idx=1:numel(Fy1)/2;
f=fs*(0:(N-1))/N;
%将原始信号绘制为时间序列
小批(311);
图(t,y1,'k');
xlabel(“时间”);
伊拉贝尔(“振幅”);
%绘制信号的频谱
小批(312);
地块(f(idx),2*Fy1(idx),'k')
xlabel(“频率(周期/秒)”;
伊拉贝尔(“振幅”);

我尝试过使用
光谱图
函数,但我很难将其结果解释为图形。如何计算光谱图,以便有时间沿X轴运行,并有振幅沿y轴运行?

您需要为
光谱图
提供更多输入参数。您需要的功能形式是:

[S,F,T]=spectrogram(x,window,noverlap,F,fs)
请参阅完整的文档,但基本上您需要定义:

  • windows
    :用于每个光谱估计计算的样本数
  • noverlap
    :计算光谱N中的光谱N-1时要包括多少个样本
  • F
    :您希望评估频谱的频率
  • fs
    :信号的采样频率
然后用以下公式绘制光谱图:

subplot(313);
imagesc( T, F, log(S) ); %plot the log spectrum
set(gca,'YDir', 'normal'); % flip the Y Axis so lower frequencies are at the bottom
注:频谱图的质量可解释性取决于对
频谱图
功能使用正确的输入