Path: blob/master/Week 2/Octave Tutorial/1. Basic Operations/basic_operations.txt
625 views
GNU Octave, version 4.4.11Copyright (C) 2018 John W. Eaton and others.2This is free software; see the source code for copying conditions.3There is ABSOLUTELY NO WARRANTY; not even for MERCHANTABILITY or4FITNESS FOR A PARTICULAR PURPOSE. For details, type 'warranty'.56Octave was configured for "x86_64-w64-mingw32".78Additional information about Octave is available at https://www.octave.org.910Please contribute if you find this software useful.11For more information, visit https://www.octave.org/get-involved.html1213Read https://www.octave.org/bugs.html to learn how to submit bug reports.14For information about changes from previous versions, type 'news'.1516#initializing a vector matrix17octave:1> A = [1 2; 3 4; 5 6];18octave:2> A19A =20211 2223 4235 62425octave:3> V = [1 2 3]26V =27281 2 32930octave:4> w = randn(1,3);31octave:5> w32w =33340.080128 0.255278 -1.0029883536octave:6> w = randn(1,3)37w =3839-1.43522 -0.29006 1.110894041octave:7> w = randn(0,3)42w = [](0x3)43octave:8> w = randn (2,3)44w =4546-2.35972 1.25747 0.7425847-0.57238 2.70842 2.204034849octave:9> w = randn(1,100)50w =5152Columns 1 through 10:5354-0.493039 0.404855 1.531180 -0.273810 0.692574 -0.376706 -0.746486 0.808372 1.082853 -0.4590045556Columns 11 through 20:5758-1.215111 -1.287317 0.217249 1.200840 -1.005836 -2.015189 0.429838 -2.455981 -0.040263 -0.8925685960Columns 21 through 30:6162-0.137333 0.612469 -0.717426 -0.996906 0.140918 0.254565 -0.206344 2.369930 -1.962787 0.1724516364Columns 31 through 40:6566-0.358356 1.904405 -0.589134 -1.612952 -1.073178 0.705945 2.251045 -0.314819 -0.324525 0.3372046768Columns 41 through 50:6970-2.607428 -2.330861 0.425313 0.855031 0.438885 1.848060 0.884042 0.627392 -1.149816 1.0412417172Columns 51 through 60:7374-0.666072 -0.863453 0.720259 2.059668 -0.212043 -0.353723 -0.594280 0.989257 -1.228740 0.8215797576Columns 61 through 70:7778-2.780196 -0.581823 1.607572 -0.210835 0.425206 0.464465 3.096434 -0.654863 -1.402686 0.8304337980Columns 71 through 80:8182-1.070995 1.342359 2.104442 1.439956 -0.262699 -0.792237 1.313962 1.488402 1.310021 -1.1794238384Columns 81 through 90:8586-1.083812 -0.335519 -1.220298 1.471193 0.692455 0.291764 0.655160 0.726798 0.673464 0.9096718788Columns 91 through 100:89900.652066 0.617140 0.484778 -0.332232 -0.737613 0.982260 -1.065312 0.011762 0.176341 0.5985779192octave:10> hist (w)93octave:11> hist (w)94octave:12> hist (w)95octave:13> hist (w)96octave:14> x = eye (5)97x =9899Diagonal Matrix1001011 0 0 0 01020 1 0 0 01030 0 1 0 01040 0 0 1 01050 0 0 0 1106107octave:15> help eye108'eye' is a built-in function from the file libinterp/corefcn/data.cc109110-- eye (N)111-- eye (M, N)112-- eye ([M N])113-- eye (..., CLASS)114Return an identity matrix.115116If invoked with a single scalar argument N, return a square NxN117identity matrix.118119If supplied two scalar arguments (M, N), 'eye' takes them to be the120number of rows and columns. If given a vector with two elements,121'eye' uses the values of the elements as the number of rows and122columns, respectively. For example:123124eye (3)125=> 1 0 01260 1 01270 0 1128129The following expressions all produce the same result:130131eye (2)132==133eye (2, 2)134==135eye (size ([1, 2; 3, 4]))136137The optional argument CLASS, allows 'eye' to return an array of the138specified type, like139140val = zeros (n,m, "uint8")141142Calling 'eye' with no arguments is equivalent to calling it with an143argument of 1. Any negative dimensions are treated as zero. These144odd definitions are for compatibility with MATLAB.145146See also: speye, ones, zeros.147148Additional help for built-in functions and operators is149available in the online version of the manual. Use the command150'doc <topic>' to search the manual index.151152Help and information about Octave is also available on the WWW153at https://www.octave.org and via the [email protected]154mailing list.155156