cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Did you know you can set a signature that will be added to all your posts? Set it here! X

How to create a matrix from certain variables

A_B
1-Newbie
1-Newbie

How to create a matrix from certain variables

Hello,

if I have set of variables such as:

a0=3 , a1=5 , a2=6 , a3= 9 , a4=2

I want to creat a matrix such as:

n= number of rows,

if I put n=3, the matrix will include a0,a1 and a2 only, the result will be like this:

M=[3

5

6]

if I put n=4, the matrix will include a0,a1,a2 and a3 only, the result will be like this:

M=[3

5

6

9]

Thank you in advance.

1 ACCEPTED SOLUTION

Accepted Solutions
Werner_E
24-Ruby V
(To:A_B)

or do you have one of those in mind?

subvectors1.png

View solution in original post

4 REPLIES 4
ValeryOchkov
24-Ruby IV
(To:A_B)

May be so:

aM.png

Werner_E
24-Ruby V
(To:A_B)

or do you have one of those in mind?

subvectors1.png

Werner Exinger wrote:

or do you have one of those in mind?

subvectors1.png

I t is the diag function?

diag.png

Valery Ochkov wrote:

I t is the diag function?

As you can see I used the diag function in the definition of subM, but A_B seems to be after some kind of extraction/subvector kind of thing.

I'm not absolutely sure but from his description I think that my "subv" is what he is searching for.

Top Tags