Skip to content
2-D analogue to Sub...
 
Notifications
Clear all

[Solved] 2-D analogue to Subset( ) ?

2 Posts
1 Users
3 Reactions
1,514 Views
Avatar
Posts: 26
Moderator
Topic starter
(@drice)
Member
Joined: 3 years ago

I'm sharing a question a user asked me:

 

If you have a 1-D array of 1s and 0s (true and false), I know how to use Subset to get a list of the index items where the 1s occur. But what if I have a 2-D array (or more) or 1s and 0s -- is there a way for me to get a list of the coordinates where the 1s occur?

1 Reply
Avatar
Posts: 26
Moderator
Topic starter
(@drice)
Member
Joined: 3 years ago

Here is my solution:

   LocalIndex Ind := IndexesOf(A);
   MdArrayToTable(A)[.Col=Ind]

This is demonstrated in this model. There are other ways of doing it, and if you see another good way, feel free to add it to this thread. 

Reply
Share:

Download the free edition of Analytica

The free version of Analytica lets you create and edit models with up to 101 variables, which is pretty substantial since each variable can be a multidimensional array. It also lets you run larger modes in ‘browse mode.’ Learn more about the free edition.

While Analytica doesn’t run on macOS, it does work with Parallels or VMWare through Windows.


    Analytica Cubes Pattern

    Download the free edition of Analytica

    The free version of Analytica lets you create and edit models with up to 101 variables, which is pretty substantial since each variable can be a multidimensional array. It also lets you run larger modes in ‘browse mode.’ Learn more about the free edition.

    While Analytica doesn’t run on macOS, it does work with Parallels or VMWare through Windows.


      Analytica Cubes Pattern