Matlab/Octave |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Vector
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 !!!
Vector (One Dimmensional Array)
Vector (One Dimmensional Array)
Method 1 : v = [ value value value value ...]
Ex)
Method 2 : v = start:step:end
Ex)
< Creating a vector with linspace >
Method 1 : v = linspace(start_value,end_value,num_of_data)
Ex)
Case 1 : v = vector1 + vector2
Ex)
Case 2 : v = vector1 - vector2
Ex)
Case 3 : v = vector1 . vector2 (Inner Product)
Ex)
Case 4 : v = vector1 x vector2 (multiplication of each elements)
Ex)
Case 5 : v = vector1 / vector2 (division of each elements)
Ex)
Case 6 : v = scalar + vector2
Ex)
Case 7 : v = scalar x vector2
Ex)
Case 1 : v = function(vector)
Ex)
Ex)
Case 1 : v = vector (index)
Ex)
Case 2 : v = vector ([index range])
Ex)
Case 3 : v = vector ([index list])
Ex)
Case 4 : v = vector (end)
Ex)
Case 1 : v = [v1 v2] // All the logic is same
Ex)
Ex)
Ex)
Case 1 : Removing/Deleting one element from a Vector
Ex)
Case 2 : Removing/Deleting multiple elements from a Vector
Ex)
< Rearranging Elements - shift() >
Case 1 : v = shift(vector,N) // Where N is a Positive Number
Ex)
Case 2 : v = shift(vector,N) // Where N is a Negative Number
Ex)
< Getting the size of a vector : size() >
Case 1 : v = size(v) // returns number of cols and number of rows of v
Ex)
Case 2 : v = size(v,1) // returns the number of rows of v
Ex)
Case 3 : v = size(v,2) // returns the number of rows of v
Ex)
< Getting the size of a vector : length() >
Case 1 : v = length(v) // returns number of elements of v
Ex)
Case 1 : v = reshape(vector,rows,cols)
Ex)
Case 1 : v_n = norm(realvector);
Ex)
norm() performs following procedure.
Case 2 : v_n = norm(complexvector);
Ex)
norm() performs following procedure.
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||