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

Community Tip - You can Bookmark boards, posts or articles that you'd like to access again easily! X

Removing lines containing zero from vector in Matcad Prime

Tomek1
5-Regular Member

Removing lines containing zero from vector in Matcad Prime

Dear Community

 

I would like to remove all lines containing zeros from my vector. Please help.

 

Regards, 
Tomek

ACCEPTED SOLUTION

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

I have modified my routine from this thread

https://community.ptc.com/t5/PTC-Mathcad-Questions/how-to-remove-zero-value-in-matrix/m-p/171978/highlight/true#M67583

a bit so it returns the matrix unchanged only if it contains no zeros and returns an error message if every row contains at least one zero. You may change the latter to something like returning a NaN or a 0 or a string.

Nevertheless as already written in the other thread, the used built-in match command has its bugs as it will compare values only with the tolerance given by the system variable TOL (even when using the modifyer; "eq" will do the same as "near") which can led to some unexpected and undesirable effects. I show an example below.

B1.png

So I would rather use the second function given here for better reliability:

B2.png

 

Worksheet in Format P4 attached.

View solution in original post

1 REPLY 1
Werner_E
25-Diamond I
(To:Tomek1)

I have modified my routine from this thread

https://community.ptc.com/t5/PTC-Mathcad-Questions/how-to-remove-zero-value-in-matrix/m-p/171978/highlight/true#M67583

a bit so it returns the matrix unchanged only if it contains no zeros and returns an error message if every row contains at least one zero. You may change the latter to something like returning a NaN or a 0 or a string.

Nevertheless as already written in the other thread, the used built-in match command has its bugs as it will compare values only with the tolerance given by the system variable TOL (even when using the modifyer; "eq" will do the same as "near") which can led to some unexpected and undesirable effects. I show an example below.

B1.png

So I would rather use the second function given here for better reliability:

B2.png

 

Worksheet in Format P4 attached.

Announcements

Top Tags