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

 

12-Amethyst
January 5, 2021

I really appreciate the  solution, thanks.

25-Diamond I
January 5, 2021

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