can't solve matrix dimensions error with noise signal
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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;
Réponses (1)
Walter Roberson
le 6 Juin 2017
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(:);
Voir également
Catégories
En savoir plus sur Signal Processing Toolbox dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!