필터 지우기
필터 지우기

Error using plot !

조회 수: 2 (최근 30일)
Osman osmanavci
Osman osmanavci 2020년 5월 7일
답변: Tommy 2020년 5월 7일
sinyal=audiorecorder(44100,16,1);
disp('start speaking')
recordblocking(sinyal,5);
play(sinyal);
myrec=getaudiodata(sinyal);
audiowrite('ses.wav', myrec, 44100);
z=myrec
figure
voicefft = fft(z);
magnitude=abs(voicefft);
anglefft=angle(voicefft);
magx=max(magnitude);
subplot(211);
plot(abs(voicefft));
title('magnitude');
subplot(212);
plot(unwrap(angle(voicefft)));
title('phase');
f=10000;
Amp=2;
fs = 44100;
ts=1/44100;
T=5;
t=0:ts:T;
y=Amp*sin(2*pi*f*t);
x1=y';
y_noisy=z+x1(1:length(z));
figure
noisyfft = fft(z);
magnoisy=abs(noisyfft);
anglenoisy=angle(noisyfft);
subplot(211);
plot(abs(noisyfft));
title('magnitude');
subplot(212);
plot((angle(noisyfft)));
title('phase');
figure
plot(t,z);
xlim([0 0.004]);
figure
plot(t,y_noisy);
xlim([0 0.004]);
figure
plot(t,y);
xlim([0 0.004]);
figure
plot(abs(z));
xlim([0 200]);
figure
plot(angle(z));
xlim([0 200]);
figure
plot(abs(y_noisy));
xlim([0 200])
figure
plot(angle(y_noisy));
xlim([0 200]);
audiowrite('bozukses.wav', y_noisy, 44100);
nfilt = 70;
Fst = 9000;
d = designfilt('lowpassfir','FilterOrder',nfilt, ...
'CutoffFrequency',Fst,'SampleRate',fs);
xf = filter(d,y_noisy);
plot(t,xf,'-r','linewidth',1.5);
title 'Electrocardiogram'
xlabel 'Time (s)', legend('Original Signal','Filtered Signal')
grpdelay(d,f,fs)
delay = mean(grpdelay(d))
tt = t(1:end-delay);
sn = z(1:end-delay);
sf = xf;
sf(1:delay) = [];
plot(tt,sn);
plot(tt,sf,'-r','linewidth',1.5);
title 'Electrocardiogram'
xlabel('Time (s)'), legend('Original Signal','Filtered Shifted Signal')
►This my script codes but i give two errors.Error is 'Vectors must be same length' and 'LİNE (49) plot (t,z);'
How can ı fix these errors, please show my solution in my codes.

답변 (1개)

Tommy
Tommy 2020년 5월 7일
z has length (44100 1/s) * (5 s) = 220500. t has length 220501. You could use linspace to ensure t has the correct length:
t = linspace(0, T, T*fs);

카테고리

Help CenterFile Exchange에서 Multirate Signal Processing에 대해 자세히 알아보기

제품


릴리스

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by