Skip to main content
12-Amethyst
January 5, 2021
Solved

Filtering zeros from nesded array

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

 

Thanks.

Werner_E
Werner_EAnswer
25-Diamond I
January 5, 2021

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

 

5 replies

Werner_E
Werner_E25-Diamond IAnswer
25-Diamond I
January 5, 2021

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

 

Translate
Werner_E
25-Diamond I
January 5, 2021

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

 

Translate