i am adding gaussian noise signal to an audio signal. but in plotting i am receiving an error " ??? Error using ==> plot Vectors must be the same lengths" how can i make equal vectors?
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
[y,fs,nbits]=wavread('C:\Users\HP\Desktop\s1.wav');
n=randn(size(y))*sigma+mu*ones(size(y));
ny=length(y);
nn=length(n);
N=min([ny nn]);
Y=y(1:N);
Z=n(1:N);
signal=Y+Z;
%%%%%%%%%
t = 0:1/fs:1-1/fs;
y = cos(2*pi*1000*t)+1/2*sin(2*pi*2000*t)+randn(size(t));
DF = fs/length(y);
ydft = fftshift(fft(y))
N = length(y);
f=(-1/2:1/N:1/2-1/N)*fs; %%%%%%%%%%%
t = 0:1/fs:1-1/fs;
y = cos(2*pi*1000*t)+1/2*sin(2*pi*2000*t)+randn(size(t));
DF = fs/length(signal);
signaldft = fftshift(fft(signal));
plot(f,abs(signaldft))
1 comentario
Walter Roberson
el 29 de Abr. de 2013
That would be fairly difficult considering that you have not defined "f".
Respuestas (1)
Walter Roberson
el 29 de Abr. de 2013
When you use y(1:N) then you are going to have difficulty if y has multiple channels (e.g., 2 channels for stereo) y(1:N,:) would extract the first N in each channel; y(1:N,1) for the first channel.
At the command line, please command
dbstop if error
and run your program. When it stops, please show
N, size(y), size(signal), size(signaldft), size(f)
Side note: another way of expressing
f=(-1/2:1/N:1/2-1/N)*fs;
would be
f = linspace(-fs/2, fs/2, N+1);
f(end) = [];
0 comentarios
Ver también
Categorías
Más información sobre Spectral Measurements en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!