FRF – PSD Calculation Using Welch’s Method Producing Less Sharp Peaks for a Linear System
Hi,
I am attempting to compute the Frequency Response Function (FRF) of a linear system using Welch’s method for estimating the Power Spectral Density (PSD). However, the results I obtain lack the sharp peaks expected for a linear system, and I would like guidance on whether my code or approach is correct, or if I might be missing something fundamental.
Despite using these settings and varying the parameters, the FRF I compute does not show sharp peaks that I expect for a linear system. The peaks are relatively broad, which makes it difficult to identify resonant frequencies clearly. I am uncertain whether:
My choice of parameters (e.g., nfft,window_length,noverlapnfft, window_length, noverlapnfft,window_length,noverlap) is contributing to this issue.
There might be a problem in my preprocessing or interpretation of the data.
Please advise, thankyou!
Fs = 8192;
window_length = 3144;
noverlap = 0.75*window_length;
nfft = 2048;
FileName = ‘exp1_0’;
FileStart = 1;
FileEnd = 10;
fileDirectory = ‘D:xx’;
% Define the window function
window_function = hanning(window_length);
% Initialize accumulators for averaging
sum_Pxx = 0; % Sum of auto-power spectrum of voltage
sum_Pxy = 0; % Sum of cross-power spectrum
% Loop over all test files = averaging
for filenum = FileStart:FileEnd
% Load data from each file
fullFileName = [fileDirectory, FileName, sprintf(‘%02d’, filenum), ‘.mat’];
fileData = load(fullFileName);
% Extract Velocity and Voltage Data
velocity_data = fileData.([FileName, sprintf(‘%02d’, filenum)]).Y(4).Data; % Output: Velocity (m/s)
voltage_data = fileData.([FileName, sprintf(‘%02d’, filenum)]).Y(3).Data; % Input: Voltage (V)
% Compute PSDs using Welch’s method
[Pxx, f] = pwelch(voltage_data, window_function, noverlap, nfft, Fs); % Auto-power spectrum of voltage
[Pxy, ~] = cpsd(velocity_data, voltage_data, window_function, noverlap, nfft, Fs); % Cross-power spectrum
% Accumulate results for averaging
sum_Pxx = sum_Pxx + Pxx;
sum_Pxy = sum_Pxy + Pxy;
end
% Compute FRF (H = Pxy / Pxx)
H = sum_Pxy ./ sum_Pxx;
% Convert to dB
H_mag_dB = 20 * log10(abs(H));
% Apply smoothing and moving average
window_size = 5;
smoothed_H_w = smoothdata(H_mag_dB, ‘movmean’, window_size);
% Plot FRF
figure;
plot(f, smoothed_H_w , ‘r’);
hold on;
title([‘FRF of Random Test with – Window Length: ‘, num2str(window_length), …
‘, Overlap: ‘, num2str(noverlap), …
‘, nfft: ‘, num2str(nfft)]);
xlabel(‘Frequency (Hz)’);
ylabel(‘Magnitude (dB)’);
grid on;
xlim([1 300]);
hold off;Hi,
I am attempting to compute the Frequency Response Function (FRF) of a linear system using Welch’s method for estimating the Power Spectral Density (PSD). However, the results I obtain lack the sharp peaks expected for a linear system, and I would like guidance on whether my code or approach is correct, or if I might be missing something fundamental.
Despite using these settings and varying the parameters, the FRF I compute does not show sharp peaks that I expect for a linear system. The peaks are relatively broad, which makes it difficult to identify resonant frequencies clearly. I am uncertain whether:
My choice of parameters (e.g., nfft,window_length,noverlapnfft, window_length, noverlapnfft,window_length,noverlap) is contributing to this issue.
There might be a problem in my preprocessing or interpretation of the data.
Please advise, thankyou!
Fs = 8192;
window_length = 3144;
noverlap = 0.75*window_length;
nfft = 2048;
FileName = ‘exp1_0’;
FileStart = 1;
FileEnd = 10;
fileDirectory = ‘D:xx’;
% Define the window function
window_function = hanning(window_length);
% Initialize accumulators for averaging
sum_Pxx = 0; % Sum of auto-power spectrum of voltage
sum_Pxy = 0; % Sum of cross-power spectrum
% Loop over all test files = averaging
for filenum = FileStart:FileEnd
% Load data from each file
fullFileName = [fileDirectory, FileName, sprintf(‘%02d’, filenum), ‘.mat’];
fileData = load(fullFileName);
% Extract Velocity and Voltage Data
velocity_data = fileData.([FileName, sprintf(‘%02d’, filenum)]).Y(4).Data; % Output: Velocity (m/s)
voltage_data = fileData.([FileName, sprintf(‘%02d’, filenum)]).Y(3).Data; % Input: Voltage (V)
% Compute PSDs using Welch’s method
[Pxx, f] = pwelch(voltage_data, window_function, noverlap, nfft, Fs); % Auto-power spectrum of voltage
[Pxy, ~] = cpsd(velocity_data, voltage_data, window_function, noverlap, nfft, Fs); % Cross-power spectrum
% Accumulate results for averaging
sum_Pxx = sum_Pxx + Pxx;
sum_Pxy = sum_Pxy + Pxy;
end
% Compute FRF (H = Pxy / Pxx)
H = sum_Pxy ./ sum_Pxx;
% Convert to dB
H_mag_dB = 20 * log10(abs(H));
% Apply smoothing and moving average
window_size = 5;
smoothed_H_w = smoothdata(H_mag_dB, ‘movmean’, window_size);
% Plot FRF
figure;
plot(f, smoothed_H_w , ‘r’);
hold on;
title([‘FRF of Random Test with – Window Length: ‘, num2str(window_length), …
‘, Overlap: ‘, num2str(noverlap), …
‘, nfft: ‘, num2str(nfft)]);
xlabel(‘Frequency (Hz)’);
ylabel(‘Magnitude (dB)’);
grid on;
xlim([1 300]);
hold off; Hi,
I am attempting to compute the Frequency Response Function (FRF) of a linear system using Welch’s method for estimating the Power Spectral Density (PSD). However, the results I obtain lack the sharp peaks expected for a linear system, and I would like guidance on whether my code or approach is correct, or if I might be missing something fundamental.
Despite using these settings and varying the parameters, the FRF I compute does not show sharp peaks that I expect for a linear system. The peaks are relatively broad, which makes it difficult to identify resonant frequencies clearly. I am uncertain whether:
My choice of parameters (e.g., nfft,window_length,noverlapnfft, window_length, noverlapnfft,window_length,noverlap) is contributing to this issue.
There might be a problem in my preprocessing or interpretation of the data.
Please advise, thankyou!
Fs = 8192;
window_length = 3144;
noverlap = 0.75*window_length;
nfft = 2048;
FileName = ‘exp1_0’;
FileStart = 1;
FileEnd = 10;
fileDirectory = ‘D:xx’;
% Define the window function
window_function = hanning(window_length);
% Initialize accumulators for averaging
sum_Pxx = 0; % Sum of auto-power spectrum of voltage
sum_Pxy = 0; % Sum of cross-power spectrum
% Loop over all test files = averaging
for filenum = FileStart:FileEnd
% Load data from each file
fullFileName = [fileDirectory, FileName, sprintf(‘%02d’, filenum), ‘.mat’];
fileData = load(fullFileName);
% Extract Velocity and Voltage Data
velocity_data = fileData.([FileName, sprintf(‘%02d’, filenum)]).Y(4).Data; % Output: Velocity (m/s)
voltage_data = fileData.([FileName, sprintf(‘%02d’, filenum)]).Y(3).Data; % Input: Voltage (V)
% Compute PSDs using Welch’s method
[Pxx, f] = pwelch(voltage_data, window_function, noverlap, nfft, Fs); % Auto-power spectrum of voltage
[Pxy, ~] = cpsd(velocity_data, voltage_data, window_function, noverlap, nfft, Fs); % Cross-power spectrum
% Accumulate results for averaging
sum_Pxx = sum_Pxx + Pxx;
sum_Pxy = sum_Pxy + Pxy;
end
% Compute FRF (H = Pxy / Pxx)
H = sum_Pxy ./ sum_Pxx;
% Convert to dB
H_mag_dB = 20 * log10(abs(H));
% Apply smoothing and moving average
window_size = 5;
smoothed_H_w = smoothdata(H_mag_dB, ‘movmean’, window_size);
% Plot FRF
figure;
plot(f, smoothed_H_w , ‘r’);
hold on;
title([‘FRF of Random Test with – Window Length: ‘, num2str(window_length), …
‘, Overlap: ‘, num2str(noverlap), …
‘, nfft: ‘, num2str(nfft)]);
xlabel(‘Frequency (Hz)’);
ylabel(‘Magnitude (dB)’);
grid on;
xlim([1 300]);
hold off; fft, psd MATLAB Answers — New Questions