Filtering zeros from nesded array
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Filtering zeros from nesded array
How could I remove zeros from the nested array M?, the file generated in mathcad 15 is attached.
Thanks.
Solved! Go to Solution.
- Labels:
-
Programming
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
There are many ways to skin a cat. Here is an attempt using a recursive function to deal even with deeply nested arrays:
Mathcad 15 worksheet attached
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
I really appreciate the solution, thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Thank you very much again.