Matlab/Octave |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Matrix
In this page, I would post a quick reference for Matlab and Octave. (Octave is a GNU program which is designed to provide a free tool that work like Matlab. I don't think it has 100% compatability between Octave and Matlab, but I noticed that most of basic commands are compatible. I would try to list those commands that can work both with Matlab and Octave). All the sample code listed here, I tried with Octave, not with Matlab.
There are huge number of functions which has not been explained here, but I would try to list those functions which are most commonly used in most of matlab sample script you can get. My purpose is to provide you the set of basic commands with examples so that you can at least read the most of sample script you can get from here and there (e.g, internet) without overwhelming you. If you get familiar with these minimal set of functionality, you would get some 'feeling' about the tool and then you would make sense out of the official document from Mathworks or GNU Octave which explains all the functions but not so many examples.
I haven't completed 'what I think is the minimum set' yet and I hope I can complete within a couple of weeks. Stay tuned !!!
Matrix (Two or Higher Dimmensional Array)
Method 1 : m = [ value value value ; value value value ; ...]
Ex)
Method 2 : m = [ vector ; vector ; ...]
Ex)
< Creating an Identity Matrix >
Method 1 : m = eye(M) // M x M identity matrix
Ex)
< Creating M x N Zero Matrix >
Method 1 : m = zeros(M,N)
Ex)
Method 2 : m = zeros(M) // M x M square matrix
Ex)
< Creating a M x N one matrix >
Method 1 : m = ones(M,N)
Ex)
Method 2 : m = ones(M) // M x M square matrix
Ex)
Case 1 : m = matrix1 + matrix 2;
Ex)
Case 2 : m = matrix1 .* matrix 2; // element by element multiplication
Ex)
Case 3 : m = matrix1 * matrix 2; // Inner Product
Ex)
Case 4 : m = matrix1 .^ n; // power of n for each element
Ex)
Case 5 : m = matrix1 ^ n; // matrix power
Ex)
Case 6 : tm = m'; // transpose matrix
Ex)
Case 7 : im = inv(m); // take the inverse matrix
Ex)
Case 8 : im = det(m); // take the determinant of the matrix
Ex)
< Indexing the elements - matrixname(rowindex,colindex) >
Ex)
Ex)
< Indexing the elements - matrixname(:,colindex) >
Ex)
Ex)
Ex)
Ex)
Ex)
< Indexing the elements - matrixname(rowindex,:) >
Ex)
Ex)
Ex)
Case 1 : Eigenvalue and Eigenvector
Ex)
< Decomposition - LU Decomposition >
Ex)
< Rearranging Elements - circshift() >
Case 1 : m = circshift(m1,N) // Where N is a positive Number. This shift rows
Ex)
Case 2 : m = circshift(m1,N) // Where N is a Negative Number. This shift rows
Ex)
Case 3 : m = circshift(m1,[0 N]) // Where N is a Positive Number. This shift cols
Ex)
Case 3 : m = circshift(m1,[0 N]) // Where N is a Negative Number. This shift cols
Ex)
< Rearranging Eelemetns - resize() >
Case 1 : m = resize(m1,M,N,..) // Resize Matrix m1 to be an M x N x .. matrix, where M, N is smaller than the original matrix
Ex)
Case 2 : m = resize(m1,M,N,..) // Resize Matrix m1 to be an M x N x .. matrix, where M or N is smaller than the original matrix
Ex)
Case 3 : m = resize(m1,M) // Resize Matrix m1 to be an M x M matrix
Ex)
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||