What is a matrix where to use it?

What is a matrix, how to use it? Why do I need it, I know that I do not know

8/25/2019 9:06:00 PM


4 Answers

New Answer


A matrix is a gird to store multiple rows of data. It's similar to a table, but unlike a table, a matrix can be used dynamically. A matrix that only contains one row or column is called a vector. In short, matrices are just like static arrays, but are dynamic. How to use: Let's say that there is 4 by 4 grid of solar panels. Each of which contains a value, and you also want to group the values together so that they can be compiled together. Instead of creating 4 different variables, you can create a matrix. That way they can be used together in for loops, outputting, etc. And since they're a matrix and not a static array, you can even add more solar panels to the group if needed. Check out this site for more information: http://polymathprogrammer.com/2008/08/11/matrices-for-programmers/


Matrices are especially common when dealing with geometry. For example, rotating a point by 30 degrees and then moving it by 2 in the x-direction can be encoded as a single 3x3 matrix. You then multiply a point with that matrix to get your answer. If you are rendering a 3D world you eventually have to get it onto your 2D screen and one way to do it is to do a bunch of matrix operations to flatten the scene to 2D. You can also use them to solve linear equations or do all sorts of statistical things. Matrices are a concept taken from mathematics, so you will encounter them when programming mathematical things. They are surprisingly general and they pop up everywhere.


Fuzzy Squid thanks