Programming Matlab function into simulink
显示 更早的评论
I'm trying to program an arduino due to record and do some calculations with the signal. To do that, i downloaded the arduino support package. Into simulink, i'm able to read the ecg signal, with an analoge input, but it needs to be filtered so i used the matlab function block and programmed the function below: (ecg is buffer of 10000 samples, sampled at 500Hz)
function y_filter = stats(ecg,fs,buffersize,bufferstep)
%#codegen
fcuts = [8 20];
mags = [1 0];
devs = [0.05 0.01];
[n,Wn,beta,ftype] = kaiserord(fcuts,mags,devs,fs);
h = fir1(n,Wn,ftype,kaiser(n+1,beta),'noscale');
y_filter=filtfilt(h,1,ecg);
I'm getting the following errors
All inputs must be constant.
Function 'MATLAB Function' (#23.282.331), line 15, column 5: "[n,Wn,beta,ftype] = kaiserord(fcuts,mags,devs,fs)" Launch diagnostic report. Component: MATLAB Function | Category: Coder error
Undefined function or variable 'n'. The first assignment to a local variable determines its class.
Function 'MATLAB Function' (#23.283.284), line 15, column 6: "n" Launch diagnostic report. Component: MATLAB Function | Category: Coder error
Undefined function or variable 'Wn'. The first assignment to a local variable determines its class.
Function 'MATLAB Function' (#23.285.287), line 15, column 8: "Wn" Launch diagnostic report. Component: MATLAB Function | Category: Coder error
Undefined function or variable 'beta'. The first assignment to a local variable determines its class.
Function 'MATLAB Function' (#23.288.292), line 15, column 11: "beta" Launch diagnostic report. Component: MATLAB Function | Category: Coder error
Undefined function or variable 'ftype'. The first assignment to a local variable determines its class.
Function 'MATLAB Function' (#23.293.298), line 15, column 16: "ftype" Launch diagnostic report. Component: MATLAB Function | Category: Coder error
Undefined function or variable 'n'. The first assignment to a local variable determines its class.
Function 'MATLAB Function' (#23.346.347), line 16, column 14: "n" Launch diagnostic report. Component: MATLAB Function | Category: Coder error
Undefined function or variable 'h'. The first assignment to a local variable determines its class.
Function 'MATLAB Function' (#23.411.412), line 18, column 23: "h" Launch diagnostic report. Component: MATLAB Function | Category: Coder error
-
Any help how i could fix the problem or another (better) solution to filter my ecg? it should be used to monitor a heart signal online.
采纳的回答
更多回答(1 个)
fikana cantri
2019-5-26
0 个投票
how do you solve the issue ? i have the same problem
类别
在 帮助中心 和 File Exchange 中查找有关 Arduino Hardware 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!