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

Community Tip - Learn all about the Community Ranking System, a fun gamification element of the PTC Community. X

test if a variable is a matrix

ptc-3836306
7-Bedrock

test if a variable is a matrix

Is there a way to test if a variable is a matrix in Prime 2.0?

I'm writting a function that uses the function vertflip. I want my function to accept a scaler or matrix, but vertflip only accepts matricies. So I'm looking to do something like...

vertflip(if(ismatrix(M), M, [M]))

ACCEPTED SOLUTION

Accepted Solutions

Got it. The "rows" function accepts a scalar or matrix and returns a zero if given a scalar. I just have to check if rows(x) = zero, and then return the function without the reverse operation.

View solution in original post

4 REPLIES 4

Can you use "reverse" and do it for all columns?

I was unaware of "reverse" but it won't accept a scalar either.

Ooo. Reverse accepts units. Much better than vertflip for my purposes. Thanks.

Got it. The "rows" function accepts a scalar or matrix and returns a zero if given a scalar. I just have to check if rows(x) = zero, and then return the function without the reverse operation.

Announcements

Top Tags