can't solve matrix dimensions error with noise signal

조회 수: 1 (최근 30일)
rivaldo rivaldo
rivaldo rivaldo 2017년 6월 6일
댓글: Star Strider 2017년 6월 6일
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
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 CenterFile Exchange에서 Signal Processing Toolbox에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by