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:
how to reduce array matrix dimession

Subject: how to reduce array matrix dimession

From: Worravit nova

Date: 16 Nov, 2010 18:38:04

Message: 1 of 2

Hi

I would like to reshape my array matrix from:

   13 0 0 0 0 0 0 0 0 0 0 0 0
     9 0 0 0 0 0 0 0 0 0 0 0 0
     5 0 0 0 0 0 0 0 0 0 0 0 0
     2 0 0 0 0 0 0 0 0 0 0 0 0
     6 0 0 0 0 0 0 0 0 0 0 0 0
    10 0 0 0 0 0 0 0 0 0 0 0 0
     4 0 0 0 0 0 0 0 0 0 0 0 0
     2 0 0 0 0 0 0 0 0 0 0 0 0
    11 0 0 0 0 0 0 0 0 0 0 0 0
    13 0 0 0 0 0 0 0 0 0 0 0 0
     4 0 0 5 0 0 0 0 0 0 0 0 0
     6 0 0 0 0 7 0 0 0 0 0 0 0
     8 0 0 0 0 0 0 9 0 0 0 0 0
    10 0 0 0 0 0 0 0 0 11 0 0 0
     4 0 0 3 0 0 0 0 0 0 0 0 0
     8 0 0 0 0 0 0 7 0 0 0 0 0
    12 0 0 0 0 0 0 0 0 0 0 11 0
     3 0 2 0 0 0 0 0 0 0 0 0 0
     5 0 0 0 4 0 0 0 0 0 0 0 0
     7 0 0 0 0 0 6 0 0 0 0 0 0
     9 0 0 0 0 0 0 0 8 0 0 0 0
    11 0 0 0 0 0 0 0 0 0 10 0 0
    13 0 0 0 0 0 0 0 0 0 0 0 12

to 2x2 matrix(I need only non-zero element) I tried with sparse ,sort,find but thos of them do not give me correct answer as I need.Anyone could help me please.I am new in this forum .

Thank in advance

Subject: how to reduce array matrix dimession

From: Sean de

Date: 16 Nov, 2010 18:50:05

Message: 2 of 2

"Worravit nova" <worravitnova@hotmail.com> wrote in message <ibuj2c$cm9$1@fred.mathworks.com>...
> Hi
>
> I would like to reshape my array matrix from:
>
> 13 0 0 0 0 0 0 0 0 0 0 0 0
> 9 0 0 0 0 0 0 0 0 0 0 0 0
> 5 0 0 0 0 0 0 0 0 0 0 0 0
> 2 0 0 0 0 0 0 0 0 0 0 0 0
> 6 0 0 0 0 0 0 0 0 0 0 0 0
> 10 0 0 0 0 0 0 0 0 0 0 0 0
> 4 0 0 0 0 0 0 0 0 0 0 0 0
> 2 0 0 0 0 0 0 0 0 0 0 0 0
> 11 0 0 0 0 0 0 0 0 0 0 0 0
> 13 0 0 0 0 0 0 0 0 0 0 0 0
> 4 0 0 5 0 0 0 0 0 0 0 0 0
> 6 0 0 0 0 7 0 0 0 0 0 0 0
> 8 0 0 0 0 0 0 9 0 0 0 0 0
> 10 0 0 0 0 0 0 0 0 11 0 0 0
> 4 0 0 3 0 0 0 0 0 0 0 0 0
> 8 0 0 0 0 0 0 7 0 0 0 0 0
> 12 0 0 0 0 0 0 0 0 0 0 11 0
> 3 0 2 0 0 0 0 0 0 0 0 0 0
> 5 0 0 0 4 0 0 0 0 0 0 0 0
> 7 0 0 0 0 0 6 0 0 0 0 0 0
> 9 0 0 0 0 0 0 0 8 0 0 0 0
> 11 0 0 0 0 0 0 0 0 0 10 0 0
> 13 0 0 0 0 0 0 0 0 0 0 0 12
>
> to 2x2 matrix(I need only non-zero element) I tried with sparse ,sort,find but thos of them do not give me correct answer as I need.Anyone could help me please.I am new in this forum .
>
> Thank in advance

A = nonzeros(A)
or
A = A(A~=0);

I don't understand how you're going to make it a 2x2 though because there are more than four nonzero elements.

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