How to plot the error between two signals?

O
Ottosaul · Jan 15, 2021 · 1.9K views
Question
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 PhD Expert
Answered Aug 25, 2026

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');

100% Run Guarantee 3-Hour Fast-Track Delivery

Need a Custom Version or Complete Simulation for This Problem?

Our 500+ PhD engineers build, debug, and optimize working MATLAB scripts and Simulink (.slx) models tailored to your exact assignment rubrics with zero plagiarism.

Tested on MATLAB R2024b / R2026a
Turnitin 0% Plagiarism Report
Free 7-Day Revisions Guarantee
Have a different question? Ask here

Get a Free Consultation or a Sample Assignment Review!