Commit c97b2866 authored by Aaron Erhardt's avatar Aaron Erhardt
Browse files

Add 3D-plot and differential equations to Matlab


Signed-off-by: default avatarAaron Erhardt <aaron.erhardt@t-online.de>
parent f7921b9c
......@@ -519,6 +519,22 @@ handle = subplot(2, 3, 1); % select first plot
handle.Children(1).LineWidth = 2; % get line from handle and change width
```
## 3-dimensional
### 3D-plot
```matlab
plot3(x, y, z);
```
### Meshgrid
```matlab
% Grids are simply specified by matrices of coordinates
[X Y] = meshgrid(x, y, z); % Generate grid
mesh(X, Y) % Plot mesh
mesh(X, Y, Z) % Plot mesh with Z coordinate
```
# Functions
......@@ -624,6 +640,42 @@ id = @(is,ud)is*exp(ud/0.05) % diode current
is = lsqcurvefit(id, 1e-10, u, i); % find ideal value for is to fit measured values u and i
```
## Differential equations
### First order
```matlab
% transform the equation so that u' is separated
du = @(t,u) -u/0.1; % u' = -u/0.1
U0 = 3; % start value
tspan = [0 0.5]; % time span
[t u] = ode45(du, tspan, U0); % calculate values
```
### Higher order
```matlab
% transform the equation so that y' = y1' and y'' = y2' are separated
% y1' = y2 y2' = sin(100*t) - y1 - y2
dy = @(t,y) [ y(2) ; sin(100*t) - y(1) - y(2) ];
% c)
[t y] = ode45(dy, [0 1], [1; 0]); % start at y1 = 1 and y2 = 0
```
### Options
```matlab
opts = odeset('absTol', 0.05); % set absolute error tolerance
[t y] = ode45(@pendfun, tspan, yNull, opts);
```
### Other solving algorithms
```matlab
ode23s %
```
# Control structures
## for-loop
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment