Thread Subject: matrix extraction

Subject: matrix extraction

From: jack j

Date: 7 Oct, 2009 06:12:01

Message: 1 of 3

Hi,

I've a square matrix and I want to extract it as smaller square matrices

eg)A=[0 0 1
          0 0 0
          1 0 0]

Expected result is

m=[0]
m=[0 0
      0 0]
m=[0 0 1
      0 0 0
      1 0 0]

Any help??

Subject: matrix extraction

From: Bruno Luong

Date: 7 Oct, 2009 06:28:03

Message: 2 of 3

"jack j" <12mailjack@gmail.com> wrote in message <hahbfh$2c2$1@fred.mathworks.com>...

> Any help??

help colon

Sylvester?

Bruno

Subject: matrix extraction

From: Ritesh Sood

Date: 7 Oct, 2009 06:28:03

Message: 3 of 3

Use a list. I tested out a simple example (the objective was to do the least amount of typing :)
>> A=rand(4)

A =

    0.8147 0.6324 0.9575 0.9572
    0.9058 0.0975 0.9649 0.4854
    0.1270 0.2785 0.1576 0.8003
    0.9134 0.5469 0.9706 0.1419

>> mask={[1:2], [1:2]}

mask =

    [1x2 double] [1x2 double]

>> mask{:}

ans =

     1 2


ans =

     1 2

>> A(mask{:})

ans =

    0.8147 0.6324
    0.9058 0.0975

Tags for this Thread

Add a New Tag:

Separated by commas
Ex.: root locus, bode

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.

rssFeed for this Thread

Contact us at files@mathworks.com