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

We are working to address an issue with subscription email notifications. In the meantime, be sure to check your favorite boards for new topics.

how to remove zero value in matrix

jcheah
1-Newbie

how to remove zero value in matrix

Hi Guys

Can anyone help with the issue below. i am trying to find minimum value (other than zero) in a matrix.

for example (see screenshot below), i would like to extract non-zero value from a matrix and then find the lowest value in the new matrix. appreciate if you could provide some guidance. thanks

Capture.PNG

5 REPLIES 5
RichardJ
19-Tanzanite
(To:jcheah)

This function deletes all the rows of a matrix (or vector) that contain only zeros.

Hi Richard, thanks for the prompt response.

the solution works. many thanks

Jo

Werner_E
24-Ruby V
(To:jcheah)

Here is a different approach. Its a One-Liner using functions from the Data Analysis Pack, which ist part of most Mathcad installations, I guess.

In contrary to Richards routine, when fed with a matrix it will trim all lines containing just a single zero, not only the all zero rows.

When fed with an all zero vector, it return this vector unchanged (while Richards routine throws an error, which is better, I guess).

An annoying drawback due to a limitation/bug in the built-in  match command is, that any value lower or equal than TOL is considered to be zero.

You can cope with that only by changing the value of TOL BEFORE the definition of  filterZero or by writing your own match-routine.

Werner

Tomek1
5-Regular Member
(To:Werner_E)

Hi Werner

Is there any equivalent function in mathcad prime to remove zeros?

Thanks

Tomek

Werner_E
24-Ruby V
(To:Tomek1)

The routine given here will work the very same in Prime, too.

Only difference is that instead of the "yyy on error xxx" in Mathcad you would use the equivalent "try xxx on error yyy".

 

For a more refined program and and alternative to using "match" see here:

https://community.ptc.com/t5/PTC-Mathcad-Questions/Removing-lines-containing-zero-from-vector-in-Matcad-Prime/m-p/559500/highlight/true#M181221

 

Top Tags