The Math Forum

Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Math Forum » Discussions » Software » comp.soft-sys.matlab

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: Transform matrix to vector
Replies: 21   Last Post: Nov 25, 2014 1:55 PM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]

Posts: 1,132
Registered: 3/13/09
Transform matrix to vector
Posted: Jul 6, 2009 2:08 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

I have the matrix:

A=[1 2 3;4 5 6; 6 7 8]

And I want to obtain the vector line:

1 2 3 4 5 6 7 8

What I did:

>>A = [1 2 3;4 5 6; 6 7 8] % matrix definition
>>b=A(1,:) % extract line 1 of matrix A in vector b
>>c=A(2,:) % extract line 2 of matrix A in vector c
>>d=A(3,:) % % extract line 3 of matrix A in vector d
>>result=[b c d] %concatenate the 3 vectors b,c,d in a single vector result
>>unique(result) % eliminate doubled elements from vector result

Is there another method to obtain that? I wait your advices!

Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© The Math Forum at NCTM 1994-2018. All Rights Reserved.