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

Translate the entire conversation x

Loop G rows of a matrix

Snowshoeman
12-Amethyst

Loop G rows of a matrix

I'm trying to pull G number of rows from an array.  The For loop is not working.  It gives me the whole array instead.

ACCEPTED SOLUTION

Accepted Solutions
Werner_E
25-Diamond I
(To:Snowshoeman)

In your attempt you never access a single row of the matrix. Here some comments:

Werner_E_1-1756440812859.png

 

I assume that when G=3 you want the program to return the top three rows of your matrix - independent from the setting of ORIGIN.

If you insist on using a for-loop you could do it that way using the row operator:

Werner_E_0-1756439809750.png

Personally I would prefer using a more generic utility function where the number of rows is an additional function argument:

Werner_E_1-1756439926771.png

But what exactly do you have against the "submatrix" function?

Werner_E_2-1756440082104.png

 

P11 file attached

 

 

View solution in original post

5 REPLIES 5

Program attached.

Hi,

ORIGIN is set to default of 0.  G=3 means fourth row.

Use the submatrix() function.

 

Capture.JPG

Cheers

Terry

Yeah,  I did the same.  I thought I should be able to do the same with a for loop.

Werner_E
25-Diamond I
(To:Snowshoeman)

In your attempt you never access a single row of the matrix. Here some comments:

Werner_E_1-1756440812859.png

 

I assume that when G=3 you want the program to return the top three rows of your matrix - independent from the setting of ORIGIN.

If you insist on using a for-loop you could do it that way using the row operator:

Werner_E_0-1756439809750.png

Personally I would prefer using a more generic utility function where the number of rows is an additional function argument:

Werner_E_1-1756439926771.png

But what exactly do you have against the "submatrix" function?

Werner_E_2-1756440082104.png

 

P11 file attached

 

 

Thank You. I like the method of calling out the number of rows in the function's argument.  

 

Nothing against the submatrix command.  But your programming is more intuitive for me.

Announcements

Top Tags