Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
matrix multiplication problem

Subject: matrix multiplication problem

From: Milos Milenkovic

Date: 7 Feb, 2012 18:26:10

Message: 1 of 4

A =
     2 3 4 5 6 7
     1 2 3 3 4 5

B =
     0 2 4 2 3 4
     3 4 6 4 7 8

>> A1 = A(:,1:3:n); A2 = A(:,2:3:n); A3 = A(:,3:3:n);
 B1 = B(:,1:3:n); B2 = B(:,2:3:n); B3 = B(:,3:3:n);
 C1 = A2*B1+(A1-A2)*B2; C2 = A2*B2; C3 = A3*B2+A2*(B3-B2);
 C(:,3:3:end) = C3; C(:,2:3:end) = C2; C(:,1:3:end) = C1;

Dear,
what this means:
??? Error using ==> mtimes
Inner matrix dimensions must agree.
Best,
Milos

Subject: matrix multiplication problem

From: Greg Heath

Date: 7 Feb, 2012 19:29:03

Message: 2 of 4

On Feb 7, 1:26 pm, "Milos Milenkovic" <m.milenko...@mathworks.com>
wrote:
> A =
>      2     3     4     5     6     7
>      1     2     3     3     4     5
>
> B =
>      0     2     4     2     3     4
>      3     4     6     4     7     8
>
> >> A1 = A(:,1:3:n); A2 = A(:,2:3:n); A3 = A(:,3:3:n);
>
>  B1 = B(:,1:3:n); B2 = B(:,2:3:n); B3 = B(:,3:3:n);
>  C1 = A2*B1+(A1-A2)*B2; C2 = A2*B2; C3 = A3*B2+A2*(B3-B2);
>  C(:,3:3:end) = C3; C(:,2:3:end) = C2; C(:,1:3:end) = C1;
>
> Dear,
> what this means:
> ??? Error using ==> mtimes
> Inner matrix dimensions must agree.
> Best,
> Milos

Delete the semicolons fom the end of the commands and inspect the
result of each command.

Hope this helps.

Greg

Subject: matrix multiplication problem

From: Roger Stafford

Date: 7 Feb, 2012 22:21:13

Message: 3 of 4

"Milos Milenkovic" <m.milenkovic@mathworks.com> wrote in message <jgrqc2$d5n$1@newscl01ah.mathworks.com>...
> A =
> 2 3 4 5 6 7
> 1 2 3 3 4 5
>
> B =
> 0 2 4 2 3 4
> 3 4 6 4 7 8
>
> >> A1 = A(:,1:3:n); A2 = A(:,2:3:n); A3 = A(:,3:3:n);
> B1 = B(:,1:3:n); B2 = B(:,2:3:n); B3 = B(:,3:3:n);
> C1 = A2*B1+(A1-A2)*B2; C2 = A2*B2; C3 = A3*B2+A2*(B3-B2);
> C(:,3:3:end) = C3; C(:,2:3:end) = C2; C(:,1:3:end) = C1;
>
> Dear,
> what this means:
> ??? Error using ==> mtimes
> Inner matrix dimensions must agree.
> Best,
> Milos
- - - - - - - -
  Milos, in that code I gave you in the other thread I intended to use 'end' instead of 'n'. They should read:

 A1 = A(:,1:3:end); A2 = A(:,2:3:end); A3 = A(:,3:3:end);
 B1 = B(:,1:3:end); B2 = B(:,2:3:end); B3 = B(:,3:3:end);
 C1 = A2*B1+(A1-A2)*B2; C2 = A2*B2; C3 = A3*B2+A2*(B3-B2);
 C(:,3:3:end) = C3; C(:,2:3:end) = C2; C(:,1:3:end) = C1;

Using the original version, if you happened to have the wrong value for n floating around you would get the error you described.

Roger Stafford

Subject: matrix multiplication problem

From: Milos Milenkovic

Date: 8 Feb, 2012 06:26:10

Message: 4 of 4

"Roger Stafford" wrote in message <jgs84p$2sf$1@newscl01ah.mathworks.com>...
> "Milos Milenkovic" <m.milenkovic@mathworks.com> wrote in message <jgrqc2$d5n$1@newscl01ah.mathworks.com>...
> > A =
> > 2 3 4 5 6 7
> > 1 2 3 3 4 5
> >
> > B =
> > 0 2 4 2 3 4
> > 3 4 6 4 7 8
> >
> > >> A1 = A(:,1:3:n); A2 = A(:,2:3:n); A3 = A(:,3:3:n);
> > B1 = B(:,1:3:n); B2 = B(:,2:3:n); B3 = B(:,3:3:n);
> > C1 = A2*B1+(A1-A2)*B2; C2 = A2*B2; C3 = A3*B2+A2*(B3-B2);
> > C(:,3:3:end) = C3; C(:,2:3:end) = C2; C(:,1:3:end) = C1;
> >
> > Dear,
> > what this means:
> > ??? Error using ==> mtimes
> > Inner matrix dimensions must agree.
> > Best,
> > Milos
> - - - - - - - -
> Milos, in that code I gave you in the other thread I intended to use 'end' instead of 'n'. They should read:
>
> A1 = A(:,1:3:end); A2 = A(:,2:3:end); A3 = A(:,3:3:end);
> B1 = B(:,1:3:end); B2 = B(:,2:3:end); B3 = B(:,3:3:end);
> C1 = A2*B1+(A1-A2)*B2; C2 = A2*B2; C3 = A3*B2+A2*(B3-B2);
> C(:,3:3:end) = C3; C(:,2:3:end) = C2; C(:,1:3:end) = C1;
>
> Using the original version, if you happened to have the wrong value for n floating around you would get the error you described.
>
> Roger Stafford

Dear Roger,
thanks and once again thanks!! Sorry for this last stupid question, I didn't use Matlab for a long time. Some matrices are quadratic so n*3n is suitable, but for the other I will make appropriate adjustments that is not the problem. The computations for single case involve some 760*760, but for fuzzy that will be 760*(760*3). Sorry if I ask a few questions more.
Best,
Milos

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us