I did the filtering of an EEG signal using fir filter then i implement this fiter in c langage. Now i need to plot the error between the to filter but i don't know how to do that. Can anyone help me please.
John Williams answered .
2025-11-20
I can help you plot the error between the two signals. Here's a step-by-step guide on how to do it in MATLAB:
Load your signals: Assuming you have two signals: one filtered using MATLAB and the other filtered using your C implementation.
Calculate the error: Subtract one signal from the other to get the error signal.
Plot the signals and the error: Use MATLAB plotting functions to visualize the original, filtered, and error signals.
% Load your signals
% Assuming your signals are in variables 'signal_matlab' and 'signal_c'
% Replace these with your actual signal variables
% Example signals (replace with your actual data)
signal_matlab = load('signal_matlab.mat'); % Load MATLAB filtered signal
signal_c = load('signal_c.mat'); % Load C filtered signal
% Calculate the error
error_signal = signal_matlab - signal_c;
% Plot the signals
figure;
subplot(3, 1, 1);
plot(signal_matlab);
title('Filtered Signal - MATLAB');
xlabel('Time');
ylabel('Amplitude');
subplot(3, 1, 2);
plot(signal_c);
title('Filtered Signal - C Implementation');
xlabel('Time');
ylabel('Amplitude');
subplot(3, 1, 3);
plot(error_signal);
title('Error Signal');
xlabel('Time');
ylabel('Amplitude');