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

Community Tip - Did you get an answer that solved your problem? Please mark it as an Accepted Solution so others with the same problem can find the answer easily. X

Filtering zeros from nesded array

rcallisaya
11-Garnet

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.

Top Tags