Answers.Body: <p>This application does seem to be pushing the limits of the official software provided by LEGO. If you are interested in C/C++ (or any other programming language), check out <a href="http://www.ev3dev.org" rel="nofollow">http://www.ev3dev.org</a>.</p>
  
  <p>I like to say that ev3dev is not firmware since it runs from a microSD card and is not loaded into the flash memory on the EV3. Nevertheless, it is an alternate operating system for the EV3 with the goal of being able to program in any language that you like. You can find a list of existing programming libraries <a href="http://www.ev3dev.org/docs/libraries/" rel="nofollow">here</a>.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-01-27T13:07:25.513Z
Answers.Text: I think i'll try this and see how it goes.. :)
Answers.UserDisplayName: Bob Burt
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-01-19T19:14:44.870Z
Answers.LastActivityDate: 2016-01-19T19:14:44.870Z
Answers.UserDisplayName: David Lechner
Answers.Body: <p>EV3-G supports single dimensional arrays only.  You could write one array that is m times n in length where m is the number of rows, and n is the number of columns.  The correct row of the single dimensional array would be (col-1)*n+row.  You would have to write a myBlock to convert 2D index values to 1D index values and vice versa.  However, doing matrix manipulations in EV3-G is painful.  Using the array block, all you can really do is read at an index, write at an index, append, and calculate array length.  This would cover most of your goals (assuming you convert the 2D to a 1D array).  Possible, but painful.  ev3dev, LeJOS, or RobotC all would be better methods and they support multidimensional arrays.     </p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-01-19T20:37:36.813Z
Answers.LastActivityDate: 2016-01-19T20:37:36.813Z
Answers.UserDisplayName: A Brown
Body: <p>I at the moment am trying to make an EV3 robot which is capable of following a gradient decent method. The idea was to store a discretized function in a 2D matrix, and make several lookups in that 2D matrix where I compute the difference between its position and its neighbor's position. and then make the robot move in the direction with descending gradient. </p>
  
  <p>To do so... </p>
  
  <p>How do I use the EV3 software to:</p>
  
  <ul>
  <li>Create a Matrix?</li>
  <li>Store values in matrix?</li>
  <li>Make lookups in matrix?</li>
  <li>Subtract those lookups?</li>
  </ul>
  
  <p>This could be way easier in C++, but is there any supported firmware capable of running C or C++ in the same way as with NXC or something like this? Something with some form of documentation?</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2016-01-19T14:35:06.867Z
Comments.Text: Have you looked at [LeJOS](http://www.lejos.org/ev3.php)? Java for the EV3 ... pretty sure you can get this done there.
Comments.UserDisplayName: Phil B.
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2016-01-19T14:37:14.273Z
Comments.Text: Java.. yeah, could i be done using c/c++?
Comments.UserDisplayName: Bob Burt
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2016-01-19T14:52:33.467Z
Comments.Text: Sure, check out [RobotC](http://www.robotc.net/download/lego/)
Comments.UserDisplayName: Phil B.
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2016-01-19T14:57:16.730Z
Comments.Text: Problem is that i have to buy it, and the trial only runs for 10 days, which wouldn't be sufficient amount of time to test it, and see whether the coded solution has the wanted easiness..
Comments.UserDisplayName: Bob Burt
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2016-01-19T14:59:53.273Z
Comments.Text: Then check out this post on our sister site StackOverflow: http://stackoverflow.com/questions/28526200/how-to-program-lego-mindstorms-ev3-using-c-language
Comments.UserDisplayName: Phil B.
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2016-01-19T14:59:56.330Z
Comments.Text: I don't have 10 consecutive days to test whether the solution i seek my needs.
Comments.UserDisplayName: Bob Burt
Tags: <ev3><software><nxc>
Title: How to store a matrix of values and pick out certain elements and compute the difference?
UserDisplayName: Bob Burt
ThreadText: # How to store a matrix of values and pick out certain elements and compute the difference?
  
  (Asked by: username_0 on 2016-01-18)
  
  I at the moment am trying to make an EV3 robot which is capable of following a gradient decent method. The idea was to store a discretized function in a 2D matrix, and make several lookups in that 2D matrix where I compute the difference between its position and its neighbor's position. and then make the robot move in the direction with descending gradient.
  
  To do so...
  
  How do I use the EV3 software to:
  
  * Create a Matrix?
  * Store values in matrix?
  * Make lookups in matrix?
  * Subtract those lookups?
  
  This could be way easier in C++, but is there any supported firmware capable of running C or C++ in the same way as with NXC or something like this? Something with some form of documentation?
  
  **Tags:** ev3, software, nxc
  > **Comments:**
  > **username_1**: Have you looked at [LeJOS](http://www.lejos.org/ev3.php)? Java for the EV3 ... pretty sure you can get this done there.  
  > **username_0**: Java.. yeah, could i be done using c/c++?  
  > **username_1**: Sure, check out [RobotC](http://www.robotc.net/download/lego/)  
  > **username_0**: Problem is that i have to buy it, and the trial only runs for 10 days, which wouldn't be sufficient amount of time to test it, and see whether the coded solution has the wanted easiness..  
  > **username_1**: Then check out this post on our sister site StackOverflow: http://stackoverflow.com/questions/28526200/how-to-program-lego-mindstorms-ev3-using-c-language  
  > **username_0**: I don't have 10 consecutive days to test whether the solution i seek my needs.  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_2 on 2016-01-19. Score: 2
  
  This application does seem to be pushing the limits of the official software provided by LEGO. If you are interested in C/C++ (or any other programming language), check out <http://www.ev3dev.org>.
  
  I like to say that ev3dev is not firmware since it runs from a microSD card and is not loaded into the flash memory on the EV3. Nevertheless, it is an alternate operating system for the EV3 with the goal of being able to program in any language that you like. You can find a list of existing programming libraries [here](http://www.ev3dev.org/docs/libraries/).
  
  > **Comments:**
  > **username_0**: I think i'll try this and see how it goes.. :)  
  
  ---
  
  ### Answer by username_3 on 2016-01-19. Score: 0
  
  EV3-G supports single dimensional arrays only. You could write one array that is m times n in length where m is the number of rows, and n is the number of columns. The correct row of the single dimensional array would be (col-1)\*n+row. You would have to write a myBlock to convert 2D index values to 1D index values and vice versa. However, doing matrix manipulations in EV3-G is painful. Using the array block, all you can really do is read at an index, write at an index, append, and calculate array length. This would cover most of your goals (assuming you convert the 2D to a 1D array). Possible, but painful. ev3dev, LeJOS, or RobotC all would be better methods and they support multidimensional arrays.
  
  
  ---
  
  