| Home | My Accounts | Newsletter | News Flash | Contact Us | Search |
|
  |
See also Getting Started with MATLAB at MCSR, Part I and Setting Up the MATLAB Environment at MCSR This is a short article showing users how to solve a 3 by 3 linear equation and how to obtain the inverse of a non-singular matrix using version 7.0 release 14 of Matlab on willow. These examples should also work using the Matlab 13 installation on sweetgum. Also discussed here are an example of how to obtain the covariance for a matrix and a small example of an eigenvalues problem. The five examples mentioned here are simple and elementary; later articles will expand this effort to include more advanced topics. Once you have set up your willow or sweetgum account, according to the above instructions in Setting Up the MATLAB Environment at MCSR to run matlab via command-line on sweetgum or willow, you can activate Matlab on willow or sweetgum, and run the following examples.
The above command activates Matlab and the double prompt “>>” below indicates that Matlab is at your service. You can continue
You can then enter a 3 by 3 non-singular matrix as follows:
Matlab will respond by printing your input matrix like this:
Next, you can enter an input vector, like this:
Matlab should respond like this:
Continue as follows:
; by vector “b” and put the results into vector x: Matlab should respond by printing the one by three vector “x” which is the solution.
For a complete discussion on solving a set of linear equations, users may look under: http://www.mcsr.olemiss.edu/appssubpage.php?pagename=imsl.inc Below is the second example of solving linear equations. This set of equations is the same as those solved using IMSL, as reported in the above website.
Above is the 3 by 3 non-singular matrix entered by the user.
Matlab responds as shown above by printing the user’s input matrix.
Above is the user’s input vector.
Again, Matlab prints the vector “c” entered by the user.
; “b” and put the result (answer) into vector x:
And the above one by three vector “x” is the solution to the original three by three matrix “a” and the vector “c”. The above three by three set of equations are solved using both IMSL and Matlab. Users may compare the two packages (IMSL and Matlab) and decide which package better fits their needs, since IMSL requires a lot of Fortran programming and Matlab does not.
Above is the 3 by 3 non-singular matrix entered by the user. To obtain the inverse of a non-singular matrix “a” above, user enters at the Matlab prompt:
To obtain the covariance of a matrix, user enters at the Matlab prompt:
To obtain an eigenvalues of a matrix that is called s1, user enters:
Matlab responds by printing the user’s input matrix.
To obtain the actual eigenvalues, the user enters:
; And the answer is:
From the study of eigenvalues we know that the eigenvaules are the solution to the following quadratic equation: X**2 -2X
-3=0. By inspection we see that -1 and 3 are the solution. “;” Indicates comments entered by the author and is not a part of Matlab programming. Comments: In our next
article we will explain the role of eigenvalues and eigenfunctions in math, physics and engineering and will
obtain eigenfunctions using both IMSL and Matlab. From the study of Matrix Algebra we know that the
inverse of an inverse is the original matrix, it is left to the users to check
this out. A graduate course in matrix algebra and another one in mathematical
statistics will help users follow this short article and some of the other Matlab’s contents. The website for our article on solving linear equations using IMSL is: |
