% % Math 451 - DeLillo - Fall 2012 diary % % Here is what I did in class on Aug. 22, 2012. % (Some of the html output may look a little strange % but the MATLA commands should be readable.) % % tanh(e) {??? Undefined function or variable 'e'. } e=exp(1) e = 2.7183 format long e e = 2.718281828459046 tanh(e) ans = 0.991328915800600 tanh(1) ans = 0.761594155955765 help log LOG Natural logarithm. LOG(X) is the natural logarithm of the elements of X. Complex results are produced if X is not positive. See also log1p, log2, log10, exp, logm, reallog. Reference page in Help browser doc log log10(2) ans = 0.301029995663981 x=log10(2) x = 0.301029995663981 10^x ans = 2.000000000000000 Arg(1+i) {??? Undefined function or method 'Arg' for input arguments of type 'double'. } angle(1+i) ans = 0.785398163397448 pi/4 ans = 0.785398163397448 help atan ATAN Inverse tangent, result in radians. ATAN(X) is the arctangent of the elements of X. See also atan2, tan, atand. Reference page in Help browser doc atan help atan2 ATAN2 Four quadrant inverse tangent. ATAN2(Y,X) is the four quadrant arctangent of the real parts of the elements of X and Y. -pi <= ATAN2(Y,X) <= pi. See also atan. Reference page in Help browser doc atan2 atan2(1,1) ans = 0.785398163397448 angle(1+sqrt(2)*i) ans = 0.955316618124509 atan2(sqrt(2),1) ans = 0.955316618124509 load usapolgon {??? Error using ==> load Unable to read file usapolgon: No such file or directory. } load usapolygon plot(uslon,uslat) axis equal b=[1;2] b = 1 2 clc b b = 1 2 A=[2 1;1 1] A = 2 1 1 1 x=A\b x = -1.000000000000000 3.000000000000000 size(A) ans = 2 2 size(b) ans = 2 1 size(x) ans = 2 1 B=rand(5,5) B = Columns 1 through 3 0.814723686393179 0.097540404999410 0.157613081677548 0.905791937075619 0.278498218867048 0.970592781760616 0.126986816293506 0.546881519204984 0.957166948242946 0.913375856139019 0.957506835434298 0.485375648722841 0.632359246225410 0.964888535199277 0.800280468888800 Columns 4 through 5 0.141886338627215 0.655740699156587 0.421761282626275 0.035711678574190 0.915735525189067 0.849129305868777 0.792207329559554 0.933993247757551 0.959492426392903 0.678735154857773 help rand RAND Uniformly distributed pseudorandom numbers. R = RAND(N) returns an N-by-N matrix containing pseudorandom values drawn from the standard uniform distribution on the open interval(0,1). RAND(M,N) or RAND([M,N]) returns an M-by-N matrix. RAND(M,N,P,...) or RAND([M,N,P,...]) returns an M-by-N-by-P-by-... array. RAND returns a scalar. RAND(SIZE(A)) returns an array the same size as A. Note: The size inputs M, N, P, ... should be nonnegative integers. Negative integers are treated as 0. R = RAND(..., 'double') or R = RAND(..., 'single') returns an array of uniform values of the specified class. Compatibility Note: In versions of MATLAB prior to 7.7, you controlled the internal state of the random number stream used by RAND by calling RAND directly with the 'seed', 'state', or 'twister' keywords. That syntax is still supported for backwards compatibility, but is deprecated. Beginning in MATLAB 7.7, use the default stream as described in RANDSTREAM. The sequence of numbers produced by RAND is determined by the internal state of the uniform pseudorandom number generator that underlies RAND, RANDI, and RANDN. Control that default random number stream using its properties and methods. See RANDSTREAM for details about the default stream. Resetting the default stream to the same fixed state allows computations to be repeated. Setting the stream to different states leads to unique computations, however, it does not improve any statistical properties. Since MATLAB uses the same state each time it starts up, RAND, RANDN, and RANDI will generate the same sequence of numbers in each session unless the state is changed. Examples: Generate values from the uniform distribution on the interval [a, b]. r = a + (b-a).*rand(100,1); Generate integer values from the uniform distribution on the set 1:n. r = randi(100,1); Save the current state of the default stream, generate 5 values, restore the state, and repeat the sequence. defaultStream = RandStream.getDefaultStream; savedState = defaultStream.State; u1 = rand(1,5) defaultStream.State = savedState; u2 = rand(1,5) % contains exactly the same values as u1 Replace the default stream with a stream whose seed is based on CLOCK, so RAND will return different values in different MATLAB sessions. NOTE: It is usually not desirable to do this more than once per MATLAB session. RandStream.setDefaultStream(RandStream('mt19937ar','seed',sum(100*clock))); rand(1,5) See also randi, randn, RandStream, RandStream/rand, RandStream/getDefaultStream, sprand, sprandn, randperm. Overloaded methods: RandStream/rand Reference page in Help browser doc rand C=randn(5) C = Columns 1 through 3 1.034693009917860 0.888395631757642 1.438380292815098 0.726885133383238 -1.147070106969150 0.325190539456198 -0.303440924786016 -1.068870458168032 -0.754928319169703 0.293871467096658 -0.809498694424876 1.370298540095228 -0.787282803758638 -2.944284161994896 -1.711516418853698 Columns 4 through 5 -0.102242446085491 -0.030051296196269 -0.241447041607358 -0.164879019209038 0.319206739165502 0.627707287528727 0.312858596637428 1.093265669039484 -0.864879917324456 1.109273297614398 clc b=rand(5,1) b = 0.276025076998578 0.679702676853675 0.655098003973841 0.162611735194631 0.118997681558377 x=A\b {??? Error using ==> mldivide Matrix dimensions must agree. } x=B\b x = -0.984962569993773 2.439563814021091 3.312426384116443 -5.651468242811344 1.708489008830043 b-Bx {??? Undefined function or variable 'Bx'. } b-B*x ans = 1.0e-15 * 0 -0.111022302462516 0.111022302462516 0 -0.222044604925031 A A = 2 1 1 1 clc A A = 2 1 1 1 A(1,1) ans = 2 A(2,1) ans = 1 b b = 0.276025076998578 0.679702676853675 0.655098003973841 0.162611735194631 0.118997681558377 b(3) ans = 0.655098003973841 clear clc A=[1 2 3;4 5 6;7 8 9] A = 1 2 3 4 5 6 7 8 9 A(3,1)=6 A = 1 2 3 4 5 6 6 8 9 A(3,1)=7 A = 1 2 3 4 5 6 7 8 9 x=[1;0;1] x = 1 0 1 A*x ans = 4 10 16 clear clc A=[1 2;1 0] A = 1 2 1 0 B=[3 1;-1 2] B = 3 1 -1 2 A*B ans = 1 5 3 1 C=inv(A) C = 0 1.000000000000000 0.500000000000000 -0.500000000000000 A*C ans = 1 0 0 1 C*A ans = 1 0 0 1 diary off diary off