How to plot the error between two signals?

Illustration
Ottosaul - 2021-01-15T10:02:19+00:00
Question: How to plot the error between two signals?

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.

Expert Answer

Profile picture of John Williams 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:

  1. Load your signals: Assuming you have two signals: one filtered using MATLAB and the other filtered using your C implementation.

  2. Calculate the error: Subtract one signal from the other to get the error signal.

  3. Plot the signals and the error: Use MATLAB plotting functions to visualize the original, filtered, and error signals.

  4. % 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');


Not satisfied with the answer ?? ASK NOW

Get a Free Consultation or a Sample Assignment Review!