OCTAVE 's usage

In andrew's class , he talked about a software called octave. Its grammar is similar to  matlab.Here are some examples on how to use it.
(1)Load data

In order to load the data into a matrix . First you should cd to the target directory. Then use "load xxx.mat"command xxx is the name of your file. After loading , there will be a matrix called xxx.

(2)Index 
A is defined as a matrix.  A(i,:) returns the ith row vector. A(:,j) returns the jth colunmn vector. A(:) returns a column vector For example 

(3)matrix Espansion

For example:

(4)Search 

For example ,find elements which are larger than 12

data(2,1) data(1,2) data(2,2) those elements are larger than 12 . r stands for rows , c stands for columns

How to find the max value of columns or rows 

(6)Plot data

we use hold on command to plot one figure on top of  other figures.
we use subplot(rows,cols,number) command to plot several figure into one window . Rows,cols mean how many rows and columns in this window . number means which  one you want to plot.

we use imagesc(matrix name),colorbar ,colormap gray commands to visualize the matrix.

猜你喜欢

转载自blog.csdn.net/frostmonarch/article/details/79771821