Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: Help with audio code
Replies: 1   Last Post: Mar 26, 2013 10:10 AM

 Steven Lord Posts: 18,038 Registered: 12/7/04
Re: Help with audio code
Posted: Mar 26, 2013 10:10 AM

news:kir2f2\$o7e\$1@newscl01ah.mathworks.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.

--
Steve Lord
slord@mathworks.com