From d30215bfaf2420bd974eabbd561699ea664df259 Mon Sep 17 00:00:00 2001 From: Gordon Senesac Jr Date: Fri, 30 Oct 2015 20:21:30 -0500 Subject: Added a couple functions to the matlab doc. --- matlab.html.markdown | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/matlab.html.markdown b/matlab.html.markdown index ad42d9a9..9d78978e 100644 --- a/matlab.html.markdown +++ b/matlab.html.markdown @@ -123,6 +123,7 @@ x(2:end) % ans = 32 53 7 1 x = [4; 32; 53; 7; 1] % Column vector x = [1:10] % x = 1 2 3 4 5 6 7 8 9 10 +x = [1:2:10] % Increment by 2, i.e. x = 1 3 5 7 9 % Matrices A = [1 2 3; 4 5 6; 7 8 9] @@ -205,6 +206,8 @@ transpose(A) % Transpose the matrix, which is the same as: A one ctranspose(A) % Hermitian transpose the matrix % (the transpose, followed by taking complex conjugate of each element) +A' % Concise version of complex transpose +A.' % Concise version of transpose (without taking complex conjugate) @@ -254,6 +257,8 @@ axis equal % Set aspect ratio so data units are the same in every direction scatter(x, y); % Scatter-plot hist(x); % Histogram +stem(x); % Plot values as stems, useful for displaying discrete data +bar(x); % Plot bar graph z = sin(x); plot3(x,y,z); % 3D line plot @@ -400,7 +405,7 @@ exp(x) sqrt(x) log(x) log10(x) -abs(x) +abs(x) %If x is complex, returns magnitude min(x) max(x) ceil(x) @@ -411,6 +416,14 @@ rand % Uniformly distributed pseudorandom numbers randi % Uniformly distributed pseudorandom integers randn % Normally distributed pseudorandom numbers +%Complex math operations +abs(x) % Magnitude of complex variable x +phase(x) % Phase (or angle) of complex variable x +real(x) % Returns the real part of x (i.e returns a if x = a +jb) +imag(x) % Returns the imaginary part of x (i.e returns b if x = a+jb) +conj(x) % Returns the complex conjugate + + % Common constants pi NaN @@ -465,6 +478,9 @@ median % median value mean % mean value std % standard deviation perms(x) % list all permutations of elements of x +find(x) % Finds all non-zero elements of x and returns their indexes, can use comparison operators, + % i.e. find( x == 3 ) returns indexes of elements that are equal to 3 + % i.e. find( x >= 3 ) returns indexes of elements greater than or equal to 3 % Classes -- cgit v1.2.3