Data matrix

hi, I was wondering if it is possible to use a data matrix in robot c and if someone has used one if you could send me an example I would appreciate it

Yes, you can do that. I don’t have an example in code. But, for example, let’s say you want to record angles for a lift based on the number of cones you’re stacking and don’t want do have the brain do that calculation on the fly. You might do something like

int angleForNextCone[20];

Now you can store a bunch of angles and reference them by how many cones are in the stack. If memory becomes a problem, don’t use int. Switch to something like short. Or, if memory is an even bigger problem and you don’t need a lot of possibilities, drop to char.

For clarification, this would create an array, not really a matrix. You can store data in it like a 1x20 matrix, so if that is your goal go for it but matrix math will not apply; it simply stores the data. Here is a decent explanation for arrays on RobotC if you do not know what they are. If you need to operate on a matrix (add, multiply, etc. matrices), you are out of luck. RobotC does not include matrix functionality.

For clarification, that array is a matrix:
“In mathematics, a matrix (plural: matrices) is a rectangular array of numbers” ( https://en.wikipedia.org/wiki/Matrix_(mathematics) )
And you can create mxn matrices using int matrix]] if you want.

Similarly, a matrix only stores data in it. A matrix is not the same as a matrix operation. Don’t confuse operators with elements. As for matrix math… addition, subtraction, and multiplication are fairly trivial to set up using structures like for(i=0,i<m,i++){for(j=0,j<n,j++){… With the memory available in VEX, I wouldn’t want to implement anything more than those.

And, if you want to go further, you can do higher-order tensors as well. For example, a 3rd-order tensor can be done via int tensor]]]. Again, this array is a tensor:
“Just as a vector in an n-dimensional space is represented by a one-dimensional array of length n with respect to a given basis, any tensor with respect to a basis is represented by a multidimensional array.” ( https://en.wikipedia.org/wiki/Tensor )