To create a 3x3 matrix in MATLAB, you can use the following code:
main.m27 chars2 lines
This code creates a 3x3 matrix named A
with the values 1-9 in row-major order. The semicolons denote a new row.
You can also create a 3x3 matrix of zeros using the zeros
function:
main.m14 chars2 lines
Or a 3x3 identity matrix using the eye
function:
main.m12 chars2 lines
And you can access the elements of the matrix using indexing:
main.m76 chars2 lines
gistlibby LogSnag