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

Community Tip - Have a PTC product question you need answered fast? Chances are someone has asked it before. Learn about the community search. X

Filtering zeros from nesded array

rcallisaya
10-Marble

Filtering zeros from nesded array

How could I remove zeros from the nested array M?, the file generated in mathcad 15 is attached.

 

Thanks.

1 ACCEPTED SOLUTION

Accepted Solutions

What you are looking for is twofold!

You don't just want to filter the zeros but you also want to combine all nested subvectors into a single one.

What should happen, if a subvector contains a zero, too?

I guess it should be filtered, too - right?

Werner_E_0-1609808608405.png

 

View solution in original post

5 REPLIES 5

What you are looking for is twofold!

You don't just want to filter the zeros but you also want to combine all nested subvectors into a single one.

What should happen, if a subvector contains a zero, too?

I guess it should be filtered, too - right?

Werner_E_0-1609808608405.png

 

There are many ways to skin a cat. Here is an attempt using a recursive function to deal even with deeply nested arrays:

Werner_E_0-1609809232465.png

 

Mathcad 15 worksheet attached

 

I really appreciate the  solution, thanks.

I had to modify my unravel function because it returns an undesired result in case of one of the inner matrices contains all zeros:

Werner_E_0-1609818685580.png

Here is the improved version:

Werner_E_0-1609820014280.png

 

 

 

Thank you very much again.

Announcements