mathew
mathew

Reputation: 69

matrix calculations matlab

I have a 3x3 matrix as follows

ls        1      2     3
mic  1    d11    d12   d13
mic  2    d21    d22   d23
mic  3

where the matrix elements define distance between each component e.g. d11 is the distance between microphone 1 (mic 1) and loudspeaker 1 (ls 1).

each ls has a a specific gain value as follows 3x1

g1     // ls1
g2     // ls2
g3     // ls3

How would I divide each gain value to the corresponding elements within the distance matrix e.g. g1/d11, g1/d21 and g2/d12 ,g2/d22 etc and then store the values within a results matrix.

thanks

Upvotes: 0

Views: 87

Answers (1)

Shai
Shai

Reputation: 114786

use bsxfun

res = bsxfun(@rdivide, gain_vec(:)', dist_matrix);

Upvotes: 3

Related Questions