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:
Inverse and Transpose of Cell

Subject: Inverse and Transpose of Cell

From: kamuran turksoy

Date: 3 Sep, 2011 20:45:28

Message: 1 of 7

Hi Everybody,

I have a cell matrix and a cell array,

A =

  Columns 1 through 9

    [7x7 double] [7x7 double] [7x7 double] [7x7 double] [7x7 double] [7x7 double] [7x7 double] [7x7 double] [7x7 double]
    [7x7 double] [7x7 double] [7x7 double] [7x7 double] [7x7 double] [7x7 double] [7x7 double] [7x7 double] [7x7 double]
    [7x7 double] [7x7 double] [7x7 double] [7x7 double] [7x7 double] [7x7 double] [7x7 double] [7x7 double] [7x7 double]
    [7x7 double] [7x7 double] [7x7 double] [7x7 double] [7x7 double] [7x7 double] [7x7 double] [7x7 double] [7x7 double]
    [7x7 double] [7x7 double] [7x7 double] [7x7 double] [7x7 double] [7x7 double] [7x7 double] [7x7 double] [7x7 double]
    [7x7 double] [7x7 double] [7x7 double] [7x7 double] [7x7 double] [7x7 double] [7x7 double] [7x7 double] [7x7 double]
    [7x7 double] [7x7 double] [7x7 double] [7x7 double] [7x7 double] [7x7 double] [7x7 double] [7x7 double] [7x7 double]
    [7x7 double] [7x7 double] [7x7 double] [7x7 double] [7x7 double] [7x7 double] [7x7 double] [7x7 double] [7x7 double]
    [7x7 double] [7x7 double] [7x7 double] [7x7 double] [7x7 double] [7x7 double] [7x7 double] [7x7 double] [7x7 double]
    [7x7 double] [7x7 double] [7x7 double] [7x7 double] [7x7 double] [7x7 double] [7x7 double] [7x7 double] [7x7 double]

  Column 10

    [7x7 double]
    [7x7 double]
    [7x7 double]
    [7x7 double]
    [7x7 double]
    [7x7 double]
    [7x7 double]
    [7x7 double]
    [7x7 double]
    [7x7 double]

B= Columns 1 through 9

    [7x1 double] [7x1 double] [7x1 double] [7x1 double] [7x1 double] [7x1 double] [7x1 double] [7x1 double] [7x1 double]

  Column 10

    [7x1 double]

During some calculation i need A^-1 and B'. Does anybody know how to get them


Turksoy

Subject: Inverse and Transpose of Cell

From: Matt J

Date: 3 Sep, 2011 23:48:07

Message: 2 of 7

"kamuran turksoy" <kamuranturksoy@gmail.com> wrote in message <j3u3l8$gnh$1@newscl01ah.mathworks.com>...
>
>
> During some calculation i need A^-1 and B'. Does anybody know how to get them
==================

Maybe, but first you'll need to define what they are.

Subject: Inverse and Transpose of Cell

From: kamuran turksoy

Date: 22 Sep, 2011 20:29:27

Message: 3 of 7

"Matt J" wrote in message <j3uebn$ggj$1@newscl01ah.mathworks.com>...
> "kamuran turksoy" <kamuranturksoy@gmail.com> wrote in message <j3u3l8$gnh$1@newscl01ah.mathworks.com>...
> >
> >
> > During some calculation i need A^-1 and B'. Does anybody know how to get them
> ==================
>
> Maybe, but first you'll need to define what they are.

They are random matrices.

Subject: Inverse and Transpose of Cell

From: Matt J

Date: 23 Sep, 2011 14:15:31

Message: 4 of 7

"kamuran turksoy" <kamuranturksoy@gmail.com> wrote in message <j5g5r7$njh$1@newscl01ah.mathworks.com>...
> "Matt J" wrote in message <j3uebn$ggj$1@newscl01ah.mathworks.com>...
> > "kamuran turksoy" <kamuranturksoy@gmail.com> wrote in message <j3u3l8$gnh$1@newscl01ah.mathworks.com>...
> > >
> > >
> > > During some calculation i need A^-1 and B'. Does anybody know how to get them
> > ==================
> >
> > Maybe, but first you'll need to define what they are.
>
> They are random matrices.

No, A and B are cell arrays, which brings me back to my question. How do you want to define the operations A^-1 and B' for your variables A and B seeing as A and B are not matrices.

Subject: Inverse and Transpose of Cell

From: kamuran turksoy

Date: 23 Sep, 2011 19:53:12

Message: 5 of 7

"Matt J" wrote in message <j5i4a3$4h8$1@newscl01ah.mathworks.com>...
> "kamuran turksoy" <kamuranturksoy@gmail.com> wrote in message <j5g5r7$njh$1@newscl01ah.mathworks.com>...
> > "Matt J" wrote in message <j3uebn$ggj$1@newscl01ah.mathworks.com>...
> > > "kamuran turksoy" <kamuranturksoy@gmail.com> wrote in message <j3u3l8$gnh$1@newscl01ah.mathworks.com>...
> > > >
> > > >
> > > > During some calculation i need A^-1 and B'. Does anybody know how to get them
> > > ==================
> > >
> > > Maybe, but first you'll need to define what they are.
> >
> > They are random matrices.
>
> No, A and B are cell arrays, which brings me back to my question. How do you want to define the operations A^-1 and B' for your variables A and B seeing as A and B are not matrices.

A is block matrix (each element of matrix is also matrix) and B is block vector (each element of vector is matrix), isn't is possible to take inverse of a block matrix and transpose of a block vector?

Regards

Subject: Inverse and Transpose of Cell

From: Matt J

Date: 23 Sep, 2011 20:51:13

Message: 6 of 7

"kamuran turksoy" <kamuranturksoy@gmail.com> wrote in message <j5io38$ob8$1@newscl01ah.mathworks.com>...
>
> A is block matrix (each element of matrix is also matrix) and B is block vector (each element of vector is matrix), isn't is possible to take inverse of a block matrix and transpose of a block vector?
==========

No, MATLAB has no native data type called a "block matrix" or "block vector". What you have shown is a cell array and MATLAB does not understand a cell array as having any matrix-like properties. This is because it can hold data that is not even numeric, e.g.

>> A={rand(7),[2;3];'dog','apple'}

A =

    [7x7 double] [2x1 double]
    'dog' 'apple'


However, what you can do is convert A to a matrix if all of its cells can be appropriately concatenated. You can then do whatever linear algebra operations that you please, e.g.,

>> A={eye(2),ones(2);ones(2), eye(2)}

A =

    [2x2 double] [2x2 double]
    [2x2 double] [2x2 double]

>> Amatrix=cell2mat(A) %convert to matrix

Amatrix =

     1 0 1 1
     0 1 1 1
     1 1 1 0
     1 1 0 1

>> inv(Amatrix)

ans =

    0.3333 -0.6667 0.3333 0.3333
   -0.6667 0.3333 0.3333 0.3333
    0.3333 0.3333 0.3333 -0.6667
    0.3333 0.3333 -0.6667 0.3333

Subject: Inverse and Transpose of Cell

From: Bruno Luong

Date: 24 Sep, 2011 07:57:10

Message: 7 of 7

"kamuran turksoy" <kamuranturksoy@gmail.com> wrote in message <j5io38$ob8$1@newscl01ah.mathworks.com>...
>
> A is block matrix (each element of matrix is also matrix) and B is block vector (each element of vector is matrix), isn't is possible to take inverse of a block matrix and transpose of a block vector?
>

As Matt's told you, the "block" interpretation is yours, not Matlab. A matrix in Matlab is simply a numerical array. Use array to store your matrix, avoid using the slow and inconvenient cell when you can.

>> A={[1 2; 3 4] [0; 0]; [0 0] 5}

A =

    [2x2 double] [2x1 double]
    [1x2 double] [ 5]

>> cell2mat(A)

ans =

     1 2 0
     3 4 0
     0 0 5

>> b={[7; 8]; [9]}

b =

    [2x1 double]
    [ 9]

>> cell2mat(b)

ans =

     7
     8
     9

>>

>> cell2mat(A)\cell2mat(b)

ans =

   -6.0000
    6.5000
    1.8000

% Bruno

Tags for 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