"Diogo " <firstname.lastname@example.org> wrote in message news:email@example.com... > Hi, I am working on a project and I have 2 microphones connected to a > matlab function and outputting to audio device: > > (from audio device 1)----u1 > MATLAB function-----To audio device > (from audio device 2)----u2 > > This alone is working, but inside the function I am trying to make a > simple operation like this: > > x=u1; > y=u2; > > x=x-mean(x); > y=y-mean(y); > > and the system gives me the error : Size mismatch (size 1024 x 2 ~= size 1 > x 2) > > This is strange because I tested this with simple sin waves(with different > phases and amplitudes) and it worked... > > Any help pls?
You can't subtract a vector from a matrix like that. You'd need to use BSXFUN.
x = reshape(1:24, 12, 2) x = bsxfun(@minus, x, mean(x))
It worked in your mono case because MEAN of a vector is a scalar and subtracting a scalar from a vector works due to scalar expansion.