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 called away in the middle of writing a post? Don't worry you can find your unfinished post later in the Drafts section of your profile page. X

Filtering zeros from nesded array

rcallisaya
12-Amethyst

Filtering zeros from nesded array

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

 

Thanks.

ACCEPTED SOLUTION

Accepted Solutions
Werner_E
25-Diamond I
(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?

Werner_E_0-1609808608405.png

 

View solution in original post

5 REPLIES 5
Werner_E
25-Diamond I
(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?

Werner_E_0-1609808608405.png

 

Werner_E
25-Diamond I
(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:

Werner_E_0-1609809232465.png

 

Mathcad 15 worksheet attached

 

I really appreciate the  solution, thanks.

Werner_E
25-Diamond I
(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:

Werner_E_0-1609818685580.png

Here is the improved version:

Werner_E_0-1609820014280.png

 

 

 

Thank you very much again.

Announcements

Top Tags