【问题标题】:Plotting respiration signal in frequency domain on y axis while time is on x axis在 y 轴上绘制频域中的呼吸信号,而时间在 x 轴上
【发布时间】:2023-04-07 18:11:01
【问题描述】:

我有一个呼吸(呼吸)信号和 25 Hz 的采样频率,需要检测时间尺度上的最低呼吸频率在哪里,这应该可以告诉我这个人何时变得困倦。经典形式的傅立叶变换并没有给我太多有用的信息。所以,澄清一下:测量时间应该在 x 轴上,呼吸频率应该在 y 轴上。然后,我想,信号幅度越低,呼吸就越慢。应该如何处理信号以按照我需要的方式绘制它?

【问题讨论】:

  • 不是编程问题 - 试试dsp.stackexchange.com ?
  • 其实是一个脚本代码,可以用Matlab写的东西。我从 Matlab 社区的 Star Strider 那里得到了很好的回答。
  • 好的 - 你没有将你的问题标记为 Matlab(或任何其他编程语言),所以它听起来像是一个 DSP 理论问题,而不是一个编程问题。以后尝试在您的问题上使用有用且适当的标签。

标签: matlab signal-processing fft


【解决方案1】:

此代码的所有功劳归于 Star Strider。

 D = load('respiratory.txt');
    Fs = 25;                                                    % Sampling Frequency (Hz)
    Fn = Fs/2;                                                  % Nyquist Frequency
    Ts = 1/Fs;                                                  % Sampling Time (sec)
    L = numel(D);
    t = linspace(0, L, L)*Ts;                                   % Time Vector (sec)

figure(1)
plot(t, D)
grid
% axis([0  60    -850  -750])
axis([xlim    -850  -750])
xlabel('Time')
ylabel('Amplitude')

FTD = fft(D-mean(D))/L;                                     % Fourier Transform
Fv = linspace(0, 1, fix(L/2)+1)*Fn;                         % Frequency Vector
Iv = 1:numel(Fv);                                           % Index Vector

figure(2)
plot(Fv, abs(FTD(Iv))*2)
grid
axis([0  2.5    ylim])
xlabel('Frequency (Hz)')
ylabel('Amplitude')

Wp = [0.35 0.65]/Fn;                                        % Passband Frequency (Normalised)
Ws = [0.30 0.75]/Fn;                                        % Stopband Frequency (Normalised)
Rp =   1;                                                   % Passband Ripple (dB)
Rs =  50;                                                   % Stopband Ripple (dB)
[n,Ws]  = cheb2ord(Wp,Ws,Rp,Rs);                            % Filter Order
[z,p,k] = cheby2(n,Rs,Ws);                                  % Filter Design, Sepcify Bandpass
[sos,g] = zp2sos(z,p,k);                                    % Convert To Second-Order-Section For Stability

figure(3)
freqz(sos, 2^16, Fs)                                        % Filter Bode Plot

D_filtered = filtfilt(sos, g, D);                           % Filter Signal

[pks,locs] = findpeaks(D_filtered, 'MinPeakDist',40);

figure(4)
plot(t, D_filtered)
hold on
plot(t(locs), pks, '^r')
hold off
grid
% axis([0  60    ylim])
axis([0  60    -15  15])
xlabel('Time')
ylabel('Amplitude')

tdif = diff([0 t(locs)]);                                   % Time Difference Between Peaks (sec)
Dfrq = 60./tdif;                                            % Frequency (Respirations/Minute)

figure(5)
plot(t(locs), Dfrq)
grid
axis([xlim    10  40])
xlabel('Time (sec)')
ylabel('Frequency (minute^{-1})')

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-06-24
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多