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

Community Tip - New to the community? Learn how to post a question and get help from PTC and industry experts! X

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
24-Ruby V
(To:rcallisaya)

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?

5 REPLIES 5
24-Ruby V
(To:rcallisaya)

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?

24-Ruby V
(To:Werner_E)

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

11-Garnet
(To:Werner_E)

I really appreciate the  solution, thanks.

24-Ruby V
(To:rcallisaya)

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

Here is the improved version:

11-Garnet
(To:Werner_E)

Thank you very much again.

Announcements
Top Tags