DSPRelated.com
Forums

Inner Matrix

Started by happey_15 December 13, 2007
Hi All,

I would like to to know to go about rectifying the problem of "Inner
matrix dimensions must agree."

The problem occur when I try to multiply a real time sound signal with
the hanning window at 320.
Would like to know how to go about to change or modify the problem when
using Matlab.

Thanks!~
> Subject: Inner Matrix
> Posted by: "happey_15" h...@yahoo.com.sg happey_15
> Date: Thu Dec 13, 2007 7:06 am ((PST))
>
> I would like to to know to go about rectifying the problem of
> "Inner matrix dimensions must agree."
>
> The problem occur when I try to multiply a real time sound signal with
> the hanning window at 320.
> Would like to know how to go about to change or modify the problem when
> using Matlab.

You need to recall of how the matrix multiplication works: to multiply
a (N,M) matrix by a (P,S) matrix, the M and P dimensions have to be
equal M = P = K, then the multiplication produces an (N,K) x (K,S) -> (N,S)
matrix. It is seen that the inner dimensions get convoluted.

By the definition: P(i,k) = SUM A(k,l)*B(l,k), l runs from 1 through K,
the row and column indices i, k run from 1 through N and S commensurately.

E.g. a column vector (100,1) times a row vector (1,100) produces a square
matrix of (100,100) size. Vice versa, a row vector (1,100) times a column
vector (100,1) gives a scalar (1,1) -- this is the well known dot product.

Rgds,

Andrew
You don't want the 'Dot Product' which is a scaler. Use the '.*'
operator. Example ans = Sound .* Hanning. This will multiply each
corresponding value of Sound and Hanning to produce a new vector of
the same length.

The purpose of the window function is to eliminate the sharp
discontinuity at the ends of the window. The endpoints the the
windowing function is near zero. A Square window by contrast leaves a
significant discontinuity. The result is that in the frequency domain
your sound is convolved with the Fourier transform of a square wave,
(the sinc function). This is generally NOT what you want.

The reason the error occurs is if you use '*' with two vectors of N
length you will get a N x N matrix or a 1 x 1, (scaler), or an error.
This is because [1 N]*[N 1] = [1 1] and [N 1]*[1 N] = [N N] is valid
whereas [1 N] * [1 N] and [N 1] *[N 1] are not. The inner dimensions
of the multiplication pair must be the same.
Hope this helps

Jerry G

--- In a..., "happey_15" wrote:
>
> Hi All,
>
> I would like to to know to go about rectifying the problem of "Inner
> matrix dimensions must agree."
>
> The problem occur when I try to multiply a real time sound signal with
> the hanning window at 320.
> Would like to know how to go about to change or modify the problem when
> using Matlab.
>
> Thanks!~
>
Dear All,

Let me correct my misprint:

> --- In a..., Andrew Nesterov wrote:
>>
>> By the definition: P(i,k) = SUM A(k,l)*B(l,k), l runs from 1 through K,

Certainly I wanted to type SUM A(i,l)*B(l,k).

My apologies.

>> Rgds,
>>
>> Andrew
>