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

Community Tip - You can subscribe to a forum, label or individual post and receive email notifications when someone posts a new topic or reply. Learn more! X

test if a variable is a matrix

ptc-3836306
1-Newbie

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]))

1 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.

Top Tags