Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/matlab/13.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中pwelch的使用与理解_Matlab_Spectral Density - Fatal编程技术网

matlab中pwelch的使用与理解

matlab中pwelch的使用与理解,matlab,spectral-density,Matlab,Spectral Density,我正在使用matlab中的pwelch方法计算一些风速测量的功率谱。到目前为止,我已经编写了以下代码作为示例: t = 10800; % number of seconds in 3 hours t = 1:t; % generate time vector fs = 1; % sampling frequency (seconds) A = 2; % amplitude P = 1000; % period (seconds), the time it takes for the signal

我正在使用matlab中的pwelch方法计算一些风速测量的功率谱。到目前为止,我已经编写了以下代码作为示例:

t = 10800; % number of seconds in 3 hours
t = 1:t; % generate time vector
fs = 1; % sampling frequency (seconds)
A = 2; % amplitude
P = 1000; % period (seconds), the time it takes for the signal to repeat itself
f1 = 1/P; % number of cycles per second (i.e. how often the signal repeats itself every second).
y = A*sin(2*pi*f1*t); % signal

fh = figure(1);
set(fh,'color','white','Units', 'Inches', 'Position', [0,0,6,6],...
    'PaperUnits', 'Inches', 'PaperSize', [6,6]);
[pxx, f] = pwelch(y,[],[],[],fs);
loglog(f,10*(pxx),'k','linewidth',1.2);
xlabel('log10(cycles per s)');
ylabel('Spectral Density (dB Hz^{-1})');
我不能包括情节,因为我没有足够的声誉点


这有意义吗?我一直在为在情节的右侧有噪音的想法而挣扎。分解后的信号是无噪声的正弦波,这种噪声来自何处?yaxis上的值为负值这一事实是否表明这些频率可以忽略不计?另外,如果风速是以m/s为单位测量的,那么在y轴上写单位的最佳方式是什么?这能转换成对环境科学家更有意义的东西吗?

你的结果很好<代码>数据库可能令人困惑

线性图将获得良好的视野

Fs = 1000;                    % Sampling frequency
T = 1/Fs;                     % Sample time
L = 1000;                     % Length of signal
t = (0:L-1)*T;                % Time vector
y = sin(2 * pi * 50 * t);     % 50Hz signal
一种
fft
方法

NFFT = 2^nextpow2(L); % Next power of 2 from length of y
Y = fft(y,NFFT)/L;
f = Fs/2*linspace(0,1,NFFT/2+1);
subplot(1,2,1);
plot(f,2*abs(Y(1:NFFT/2+1))) 
xlabel('Frequency (Hz)') 
ylabel('|Y(f)|')
subplot(1,2,2);
[pxx, freq] = pwelch(y,[],[],[],Fs);
plot(freq,10*(pxx),'k','linewidth',1.2);
xlabel('Frequency (Hz)'); 
ylabel('Spectral Density (Hz^{-1})');
pHelpch
approach

NFFT = 2^nextpow2(L); % Next power of 2 from length of y
Y = fft(y,NFFT)/L;
f = Fs/2*linspace(0,1,NFFT/2+1);
subplot(1,2,1);
plot(f,2*abs(Y(1:NFFT/2+1))) 
xlabel('Frequency (Hz)') 
ylabel('|Y(f)|')
subplot(1,2,2);
[pxx, freq] = pwelch(y,[],[],[],Fs);
plot(freq,10*(pxx),'k','linewidth',1.2);
xlabel('Frequency (Hz)'); 
ylabel('Spectral Density (Hz^{-1})');

正如您所看到的,它们都在
50Hz处有峰值

使用
loglog
对这两个

因此,“噪声”属于
1e-6
,也存在于
fft
中,可以忽略


对于你的第二个问题,我认为轴不会改变,它将再次成为
frequency
。对于
Fs
你应该使用风速的采样频率,比如如果你在一秒钟内有
10
个风速样本,你的
Fs
就是
10
。图表中频率越高,风速变化越大;频率越低,风速变化越小。

谢谢你的回答。我知道Hz意味着每秒的周期,所以我可以使用x轴上的值来计算信号的周期。然而,每赫兹在yaxis上代表什么?这个怎么用?例如,0.8 Hz-1的频谱密度实际上意味着什么?@Emmatebs,在
y
轴中,它意味着
y
的值代表一个频率值。它就像一张速度与时间的曲线图,其中速度为(m/s),时间为
s
@Emmatebs,我认为
.8-1Hz
是你的最高频带。所以这意味着风速的急剧变化。很好的答案。谢谢我会投票,但还没有足够的代表分数。@Rashid,非常感谢!谢谢!我会先尝试完成一些紧急的事情,然后我会在这里问一个公开的问题(这可能会对将来的人有所帮助):)