Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

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


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

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: 17,944
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 " <duradurad@hotmail.com> wrote in message
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
To contact Technical Support use the Contact Us link on
http://www.mathworks.com




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

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.