can't solve matrix dimensions error with noise signal
조회 수: 1 (최근 30일)
이전 댓글 표시
I'm trying to add uniformal distributed noise to a speech signal and just dont know how to solve this error
Error using +
Matrix dimensions must agree.
x-the speech signal
nos-the noise signal
clear all;close all;clc
[x,Fs,Nbits] = wavread('jennifer.wav');
t = 0:0.001:512;
f = 45:55;
nos = sum(sin(2*pi*f'*t));
figure(1)
plot(t, nos)
grid
axis([0 2 -4 4]);
y=x+nos;
답변 (1개)
Walter Roberson
2017년 6월 6일
Your t is size 512001 -- remember that when you have 0:N that the length of that is N+1
Your f is size 11, but you sum along the dimension implied by f, so your nos comes out 1 x 512001 -- a row vector.
Your x is going to be a column vector.
In R2016a and earlier, if you attempt to add a column vector and a row vector, that would be an error. In R2016b and later, the effect would be the same as
bsxfun(@plus, x, nos)
which would return a length(x) by 512001 array; it seems unlikely that is what you want.
I would suggest
t = (0 : length(x)-1) / Fs;
f = 45:55;
nos = sum(sin(2*pi*f'*t));
y = x + nos(:);
참고 항목
카테고리
Help Center 및 File Exchange에서 Signal Processing Toolbox에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!