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 (최근 30일)
이전 댓글 표시
[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
Walter Roberson
2013년 4월 29일
That would be fairly difficult considering that you have not defined "f".
답변 (1개)
Walter Roberson
2013년 4월 29일
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
참고 항목
카테고리
Help Center 및 File Exchange에서 Spectral Measurements에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!