I have written the following function to remove noise from an EMG signal
function[EMG_filtered] = noise_removal(EMG)
Fs = 2000;
x = filter(b1,a1,EMG);
x1 = filter(b2,a2,x);
EMG_filtered = filter(b3,a3,x1);
The function is running correctly except for the fact that it does not save the output as EMG_filtered. It returns "ans" which equals EMG_filtered but this is overwritten as soon as a different function is run. I am having this problem with all the functions I am running. Am I not defining the output correctly?
Thanks for any help and advice