How to deal with this error??
이 질문을 팔로우합니다.
- 팔로우하는 게시물 피드에서 업데이트를 확인할 수 있습니다.
- 정보 수신 기본 설정에 따라 이메일을 받을 수 있습니다.
오류 발생
페이지가 변경되었기 때문에 동작을 완료할 수 없습니다. 업데이트된 상태를 보려면 페이지를 다시 불러오십시오.
이전 댓글 표시
0 개 추천
A model of the surface EMG signal is created by filtering a white gaussian noise, using a shaping filter H(f). this filter has low cut-off freq=60hz and high cut-off freq=120hz. this is my code but i don't know how to deal with Undefined function 'designfilt' for input arguments of type 'char'.
clear all;
subplot(322);
load nnoise.m;
plot(nnoise,'k');
% design shaping filter
bpFilt = designfilt('bandpassfir',...
'CutoffFrequency1',60,'CutoffFrequency2',120, ...
'SampleRate',2000);
subplot(323);
W = filter(bpFilt,nnoise);
plot(W,'k');title ('EMG');
채택된 답변
Star Strider
2017년 5월 4일
The designfilt function was introduced in the R2014a version of the Signal Processing Toolbox.
If you have an earlier version of the Signal Processing Toolbox, this filter will work, since all the functions were introduced prior to R2006a:
Fs = 2000;
notch_frq = [50 60 120 130];
mags = [0 1 0];
devs = [0.05 0.01 0.05];
[n,Wn,beta,ftype] = kaiserord(notch_frq,mags,devs,Fs);
n = n + rem(n,2);
hh = fir1(n,Wn,ftype,kaiser(n+1,beta),'scale');
figure(1)
freqz(hh, 1, 2^17, Fs)
Use the filtfilt function to do the actual filtering of your signal.
See the documentation on the various functions to understand how to use them.
댓글 수: 13
thank you sir. i'm trying but also i have this message Error using filtfilt Not enough input arguments.
subplot(322);
load nnoise.m;
plot(nnoise,'k');
% using shaping filter
Fs = 2000;
notch_frq = [50 60 120 130];
mags = [0 1 0];
devs = [0.05 0.01 0.05];
[n,Wn,beta,ftype] = kaiserord(notch_frq,mags,devs,Fs);
n = n + rem(n,2);
hh = fir1(n,Wn,ftype,kaiser(n+1,beta),'scale');
subplot(324);
W = filtfilt(hh,nnoise);
plot(W,'k');title ('EMG');
My pleasure.
The ‘hh’ returned by the fir1 function is the numerator of the filter transfer function. You need to supply the denominator, that for FIR filters is always equal to 1.
This will work:
W = filtfilt(hh, 1, nnoise);
thank you sir for your patience with me. for my case the shaping filter has a transfer function H(f). where fl= low cut-off freq and fh= high cut-off freq.
H(f)=(fh^4)*(f^2)/((f^2)+(fl^2))*((f^2)+(fh^2))^2;
so can i use W = filtfilt(hh, 1, nnoise);
also, when they ask to set the initial snr from -5 to 55 in step of 5db this formula is it correct snrin=(-5:5:55) how can i integrate the db
Star Strider
2017년 5월 4일
My code designs the filter you specified in your designfilt call. It simply uses lower-level functions.
Your ‘H(f)’ appears to design a continuous infinite impulse response (or IIR) filter. It looks like a Butterworth design, although I would have to know more. You would need to use the bilinear transform to convert a continuous filter to a discrete filter. (There are others, but the bilinear transform is the most reliable.)
I do not understand the additional requirements with respect to the SNR. If you want the filter to have that shape, you need to use the firls or firpm functions.
1. white gaussian noise is passed through shaping filter H(f)where H(f)=(fh^4)(f^2)/((f^2)+(fl^2))*((f^2)+(fh^2))^2*, fh and fl change the shape of the spectral function (the goal is create an emg model).
2. the new filtred signal (W)is multiplied by a factor A(this factor is in function of e, f and snr-in) this snr-in is from -5 to 55 in steps of 5db the formula of snr_in in my code is it correct?? because when i type snr-in=55 instead snr-in=(-5:5:55) i get acceptable result
3.noisy ecg = ecg + A*W (ecg is sampled at 360hz from physionet MIT db)
%ecg and noisy ecg clc;
clear all;
load m105a.m;
ecg=m105a;
subplot(3,2,1);
plot(ecg); title ('ECG');
xlabel('samples'); ylabel('magnitude');
subplot(322);
load nnoise.m;
plot(nnoise,'k');
% using shaping filter
Fs = 2000;
notch_frq = [50 60 120 130];
mags = [0 1 0];
devs = [0.05 0.01 0.05];
[n,Wn,beta,ftype] = kaiserord(notch_frq,mags,devs,Fs);
n = n + rem(n,2);
hh = fir1(n,Wn,ftype,kaiser(n+1,beta),'scale');
subplot(323);
W = filtfilt(hh,1,nnoise);
plot(W,'k');title ('EMG');
% noisy ecg
snrin_db=(-5:5:55); %initial snr in db
N=length(ecg);
n=(0:N-1);
e = sum( ecg(1+n).^2 );
f = sum( W(1+n).^2 );
A=sqrt(e./(10.^(snrin_db/10))*f); %the factor A in function of e and f
subplot(324);
ecgnoisy = repmat(ecg(:), 1, length(A)) + repmat(W(:), 1, length(A)) .* repmat(A, numel(W), 1);
plot(ecgnoisy,'k');title('Noisy signal');
First, since ‘ecg is sampled at 360hz’ your sampling frequency for all your signal processing must be 360 Hz.
Second, your ‘H(f)’ filter does not appear to be coded correctly. In any event, I cannot get a magnitude plot for it that is remotely close to what you want it to do. The FIR filter I designed works correctly.
Third, I have no idea how to interpret 2. in your Comment. This is apparently taken from the ‘Methods’ section of a paper, and has no context for me. I cannot determine if the SNR calculation is correct.
If you get an acceptable result for one value of ‘snrin_db’*, you most likely need to use a loop to calculate all of them:
snrin_db=(-5:5:55); %initial snr in db
N=length(ecg);
n=(0:N-1);
e = sum( ecg(1+n).^2 );
f = sum( W(1+n).^2 );
for k1 = 1:length(snrin_db)
A = sqrt(e./(10.^(snrin_db(k1)/10))*f); %the factor A in function of e and f
subplot(324);
ecgnoisy{k1} = repmat(ecg(:), 1, length(A)) + repmat(W(:), 1, length(A)) .* repmat(A, numel(W), 1);
end
I created ‘ecgnoisy’ as a cell array because I do not know its dimensions. The loop should produce a cell array element for each value of ‘snrin_db’.
I cannot run your code, so this is a guess. You may have to experiment to get the result you want.
Good mind
2017년 5월 5일
thank you so much
Star Strider
2017년 5월 5일
My pleasure.
Good mind
2017년 5월 7일
good afternoon. i' m trying with this code ?how to deal with this error .i want linear filtering.(sorry i'm beginner) Error using filter Not enough input arguments.
the numerator order=1 and the denominator order=3
% using shaping filter fs=360; [numd,dend] = bilinear([568489.21 0],[1 5217.410 749444.9503 214315384.4],fs); subplot(323); W=filter([numd,dend],nnoise); plot(W,'k');title ('EMG');
% using shaping filter
fs=360;
[numd,dend] = bilinear([568489.21 0],[1 5217.410 749444.9503 214315384.4],fs);
subplot(323);
W=filter([numd,dend],nnoise);
plot(W,'k');title ('EMG');
If you want to plot the transfer function:
fs=360;
[numd,dend] = bilinear([568489.21 0],[1 5217.410 749444.9503 214315384.4],fs);
figure(1)
freqz(numd, dend, 2^17, fs)
I would use filtfilt rather than filter. It has a maximally-flat phase response, so there is no phase distortion, and it also handles the initial conditions on its own.
Call it as:
W = filtfilt(numd,dend,nnoise);
Do not use ‘[numd,dend]’ as a filter argument to any filter function. That concatenates the numerator and denominator polynomials into one vector, resulting the the ‘Not enough input arguments.’ error you are currently getting.
Good mind
2017년 5월 7일
Mr. Strider I would like to thank you very much. you alerted me to important informations. I hope that everyone will benefit from these discussions, especially beginners.
2^17 is from where?
Star Strider
2017년 5월 7일
As always, it is my pleasure to help.
The ‘2^17’ is the length of the Fast Fourier Transform that freqz uses to compute the transfer function. I apologise for not explaining that earlier.
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Digital Filtering에 대해 자세히 알아보기
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 MathWorks 사이트 방문이 최적화되지 않았습니다.
미주
- América Latina (Español)
- Canada (English)
- United States (English)
유럽
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
