MATLAB: How to denoise raw EEG data with MATLAB

eegMATLABnoise filter

I made the program which would filter out the noise from raw EEG data, however, I could not implement the code. Could you please tell me what is wrong with this program? The program is down below.
function OutputEEG = MyEEGFilter(InputEEG,fs)
fs=SampleRate;
lowEnd = 3; % Hz

highEnd = 70; % Hz
filterOrder = 2; % Filter order (e.g., 2 for a second-order Butterworth filter). Try other values too
[b, a] = butter(filterOrder, [lowEnd highEnd]/(fs/2)); % Generate filter coefficients
d = designfilt('bandstopiir','FilterOrder',8, ...
'HalfPowerFrequency1',49,'HalfPowerFrequency2',51, ...
'DesignMethod','butter','SampleRate',fs);
InputEEG=double(InputEEG);
Foutput(1,:) = filtfilt(d,InputEEG(1,:));
Foutput(1,:) = filtfilt(b,a,Foutput(1,:));
end

Best Answer

How are you calling it? And attach InputEEG and fs in a .mat file so we can call it ourselves with your data. And be sure to define OutputEEG. Maybe it's as simple as
OutputEEG = Foutput;
As the last line of your program.