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

Community Tip - Need help navigating or using the PTC Community? Contact the community team. X

How to Find Number of Rows

ppal
17-Peridot

How to Find Number of Rows

Prime 8 . No file attached. Trivial inputs. How do I get 3 ?

ppal_0-1674181036176.png

 

 

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions

Hi

Default start of counting of rows is 0 if not defined as anything else by ORIGIN value.

Defined rows 3 to 5.  0 to 2 rows will have zero. Check by M[0=.

so 6 rows in M.

Cheers

Terry

View solution in original post

6 REPLIES 6

Hi

Default start of counting of rows is 0 if not defined as anything else by ORIGIN value.

Defined rows 3 to 5.  0 to 2 rows will have zero. Check by M[0=.

so 6 rows in M.

Cheers

Terry

ppal_0-1674185298297.png

 

Werner_E
24-Ruby V
(To:ppal)


How do I get 3 ?

 

 

 

 


Thats easy - you get 3 if you use a vector or matrix with just three rows. 😉

But the vector M you created has six elements for reason which Terry already explained.
So its correct to say that has six rows.

Give it a try yourself and type M=  You will see a six rows vector.

BTW, when you try rows(i) or rows(M[i) you feed the elements 3,4,5 one after the other in the rows() function. Each of these values is a scalar, not a matrix or vector and so the row() function returns 0 for every of these three values and thats the reason for the vector with three zeros you get as a result.

 

If you want to create a three element vector with the values 3,4,5, here is the way to go

Werner_E_0-1674184887686.png

You could also do it that way

Werner_E_1-1674184947262.png

but I would recommend the first approach.

You may even do it that way

Werner_E_0-1674185070002.png

but I would strongly advise against it.

 

 

 

ppal
17-Peridot
(To:Werner_E)

Thanks. First approach will do. 

LucMeekes
23-Emerald III
(To:Werner_E)

"If you want to create a three element vector with the values 3,4,5"...

You forgot the simplest one:

LucMeekes_0-1674250846566.png

and my favourite:

LucMeekes_1-1674250868055.png

Luc

 

Yes, you are right. And they also have the benefit of being ORIGIN-independent.

Here are a few more ... 😉

Werner_E_1-1674253268749.png

 

If needed more often, a utility function could be handy

Werner_E_0-1674254557602.png

And here a version which should also work in Express

Werner_E_1-1674254606271.png

 

 

 

 

Top Tags