What are options to filter signal during simulation ?

2 Ansichten (letzte 30 Tage)
AK
AK am 5 Aug. 2024
Bearbeitet: Umar am 3 Sep. 2024
I have two signals .
Yellow line is expected and blue line is actual response .
I want to filer blue line output signal to match yellow line as possible as I can.
The frequency of yellow line oscilations is 0.886. The perid mesured P-P is 1.128Sec.
I tried with LPF but didnt see any difference. The filtering is required to be done during simulation not after simulation.
  5 Kommentare
AK
AK am 2 Sep. 2024
I agree with you. Now I also think that its not possible to do real time filtering.Currently its not a issue because the signla fluctuations are steady and folliwng with target signal.
Thanks for the support.
Umar
Umar am 3 Sep. 2024
Bearbeitet: Umar am 3 Sep. 2024

Hi @AK,

As highlighted in @Mathieu NOE’s comments, real-time filtering poses challenges due to the potential introduction of delays. The balance between signal clarity and temporal fidelity is essential. If the application requires real-time processing, it may be necessary to compromise on the level of noise reduction to maintain signal responsiveness. One viable option at this point that I could think of is implementation of FIR (Finite Impulse Response) filter which can be designed to have linear phase characteristics, thus minimizing phase distortion and time delays while providing effective noise reduction. However, here is a refined version of my code that could be tested with varying parameters to find the optimal filter for your specific signals:

% Simulation parameters
fs = 10; % Sampling frequency (Hz)
t = 0:1/fs:10; % Time vector (10 seconds)
f_yellow = 0.886; % Frequency of yellow line (Hz)
% Generate yellow line (expected signal)
yellow_line = sin(2 * pi * f_yellow * t);
% Generate blue line (actual signal with noise)
blue_line = yellow_line + 0.1 * randn(size(t)); % Adding noise
% Apply a moving average filter
windowSize = 5; % Adjust this size based on signal characteristics
filtered_blue_line = movmean(blue_line, windowSize);
% Plotting the results
figure;
plot(t, yellow_line, 'y', 'LineWidth', 2); hold on;
plot(t, blue_line, 'b', 'LineWidth', 1);
plot(t, filtered_blue_line, 'r', 'LineWidth', 1);
legend('Yellow Line (Expected)', 'Blue Line (Actual)', 'Filtered Blue   Line');
title('Signal Filtering Example');
xlabel('Time (s)');
ylabel('Amplitude');
grid on;

I will also add additional comments by analyzing your signals in the frequency domain using the Fast Fourier Transform (FFT). This can provide insights into the frequency components of both signals and help you determine the optimal filtering approach. Now, if the characteristics of the noise change over time, adaptive filtering techniques may be beneficial because these filters adjust their parameters in real-time based on the input signal characteristics, providing more responsive filtering. So, after filtering, it’s crucial to analyze the output signal for time delays and distortions. Cross-correlation between the filtered blue line and the yellow line can help quantify the alignment and timing issues.

Hope this helps. Please let us know if you have any further questions.

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Kategorien

Mehr zu Powertrain Blockset finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by