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

Filtering zeros from nesded array

  • January 5, 2021
  • 1 reply
  • 2502 views

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

 

Thanks.

Best answer by Werner_E

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

 

1 reply

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

 

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