Why is my function not defining my outputs and just returning "ans"?

5 ビュー (過去 30 日間)
Jennifer Miller
Jennifer Miller 2015 年 6 月 23 日
コメント済み: BSantos 2015 年 6 月 23 日
I have written the following function to remove noise from an EMG signal
function[EMG_filtered] = noise_removal(EMG)
Fs = 2000;
[b1,a1]=butter(5,[48/Fs*2, 52/Fs*2],'stop');
[b2,a2]=butter(5,300/Fs*2,'low');
[b3,a3]=butter(5,10/Fs*2,'high');
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
  1 件のコメント
BSantos
BSantos 2015 年 6 月 23 日
you forgot a space in between "function" and the first bracket.

サインインしてコメントする。

採用された回答

Katalin
Katalin 2015 年 6 月 23 日
In the script where you are using the function you need to define a variable e.g
ABC = noise_removal(data);
Then it will be stored in ABC. Otherwise if you just run it it will always put the result in "ans" of any function.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangePerformance and Memory についてさらに検索

タグ

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by