Error using plot !
Afficher commentaires plus anciens
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.
Réponses (1)
Tommy
le 7 Mai 2020
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);
Catégories
En savoir plus sur Smoothing and Denoising dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!