Would taking a course in Linear Algebra help with working with Matlab?

331 Views Asked by At

I'll soon be using Matlab in an engineering course I'll be taking next semester. So given how Matlab stands for Matrix Laboratory and Linear Algebra has a lot of matrices involved, does such a Linear Algebra help with working in Matlab?

I ask this because I don't know nearly enough about Matlab or Linear Algebra to know how the two tie together if at all.

2

There are 2 best solutions below

0
On BEST ANSWER

Yes, knowing some linear algebra will 100% help you write effective and efficient Matlab code, and it will better help you understand how to apply Matlab in actual situations. One of the key aspects of writing efficient Matlab code, vectorization, can be very difficult for people who are not intimately familiar with matrix operations, and not being able to understand effective vectorization will vastly decrease the quality of Matlab programs you create. Probably more importantly though, is that if you do not know some linear algebra, you will never grasp why you are using Matlab over any of the thousands of other, better designed and more intuitive computer languages. Matlab exists for solving problems in linear algebra, and if you don't know about those problems, or understand why they are interesting, Matlab will be absolutely valueless for you.

Aside of that, learning linear algebra in a more theoretical setting - as in what the university will teach to more advanced math students, focusing on the general properties of finite dimensional vector spaces - will likely greatly improve your ability for modeling problems you will face in engineering, and greatly improve your ability to think abstractly and reason logically. I tend to think, though, that you are likely considering taking a more introductory class, and that you should be more interested in the familiarity with matrix applications it will bring you.

0
On

I'm going to give a basic example of how linear algebra knowledge has personally helped me use MATLAB effectively.

My colleague was implementing an advanced controls algorithm using MATLAB and Simulink. In short, the algorithm needed to solve a Riccati equation in real-time, among other things. One of the steps of the algorithm involved computing a matrix product of the form $AXB^T$, or something similar.

Because of numerical precision issues, the MATLAB version of the code yielded a different result than the FORTRAN version we were porting from. The residual was not large, but it was large enough to cause the controller to fail to adapt properly.

After analyzing the code, I came up with the solution to compute instead $BX^TA^T$, and then take the transpose of that, since

$$\left(BX^TA^T\right)^T = AXB^T.$$

This is a basic linear algebra identity, but knowing that the order of computations could affect the numerical precision was the key to solving the problem. After computing the values in this way, the FORTRAN and MATLAB codes ran identically.

That said, many of the "tricks" to MATLAB programming are more about efficiently shuffling data and writing more efficient code than they are about leveraging linear algebra identities and theorems. At the end of the day, MATLAB is a tool to help you more rapidly do the linear algebra you already know.