Commit 32a69b36 by Aaron Erhardt

### Final update for Matlab cheatsheet

```
Signed-off-by: Aaron Erhardt <aaron.erhardt@t-online.de>```
parent 1313c56c
Pipeline #756 passed with stage
in 1 minute and 59 seconds
 ... @@ -126,6 +126,13 @@ diag(flip(A)) % other diagonal (bottom left to top right) ... @@ -126,6 +126,13 @@ diag(flip(A)) % other diagonal (bottom left to top right) x = A \ b % solves Ax = b x = A \ b % solves Ax = b ``` ``` ## Find indices ```matlab i = find(A); % find all nonzero elements i = find(A > 1); i = find(A < 1, 5); % get the first five elements ``` # Images # Images ... @@ -134,14 +141,14 @@ x = A \ b % solves Ax = b ... @@ -134,14 +141,14 @@ x = A \ b % solves Ax = b ```matlab ```matlab img = imread('path_to_file') img = imread('path_to_file') ``` ``` ### Show image ### Show image ```matlab ```matlab imagesc(img) imagesc(img) ``` ``` Color map ### Color map ```matlab ```matlab colormap(gray()) % gray color map colormap(gray()) % gray color map ... @@ -283,6 +290,7 @@ fprintf(1, 'value: %d\n', 2) ... @@ -283,6 +290,7 @@ fprintf(1, 'value: %d\n', 2) ```matlab ```matlab save file_name save file_name save file_name a b c % only save a, b and c load file_name load file_name ``` ``` ... @@ -309,6 +317,12 @@ fclose(file_handle) ... @@ -309,6 +317,12 @@ fclose(file_handle) # Polynomials # Polynomials ## Create polynomial from roots ```matlab p = poly([1 -2 3]); ``` ## Fit polynomial to points ## Fit polynomial to points ```matlab ```matlab ... @@ -323,6 +337,17 @@ p = polyfit(x, y, deg); ... @@ -323,6 +337,17 @@ p = polyfit(x, y, deg); y = polyval(p, x); y = polyval(p, x); ``` ``` ## Multiply polynomials ```matlab p3 = conv(p1, p2); ``` ## Get roots ```matlab r = roots(p); ``` # Graphics # Graphics ... @@ -689,12 +714,39 @@ opts = odeset('absTol', 0.05); % set absolute error tolerance ... @@ -689,12 +714,39 @@ opts = odeset('absTol', 0.05); % set absolute error tolerance [t y] = ode45(@pendfun, tspan, yNull, opts); [t y] = ode45(@pendfun, tspan, yNull, opts); ``` ``` ### Other solving algorithms # Transfer functions ## Create ```matlab ```matlab ode23s % G = tf([1 0], [2 0 0]); ``` ``` ## Step response information ```matlab S = stepinfo(G); ``` ## Plot step response ```matlab orstep(G); step(G, 0.2); ``` ## Plot bode diagram ```matlab bode(G); ``` ## Plot nyquist diagram ```matlab nyquist(G); ``` # Control structures # Control structures ... @@ -802,4 +854,4 @@ for i = x ... @@ -802,4 +854,4 @@ for i = x y(cnt) = sin(i); y(cnt) = sin(i); cnt = cnt + 1; cnt = cnt + 1; end end ``` ``` \ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!