The Math Forum

Search All of the Math Forum:

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

Math Forum » Discussions » Software » comp.soft-sys.matlab

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

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View  
Steven Lord

Posts: 18,038
Registered: 12/7/04
Re: Help with audio code
Posted: Mar 26, 2013 10:10 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

"Diogo " <> wrote in message
> 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

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
To contact Technical Support use the Contact Us link on

Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© The Math Forum at NCTM 1994-2018. All Rights Reserved.