Severity: Warning
Message: fopen(/home/polpe/.phpsession/ci_session367c0578a028fffb0e29656fa24ce1bb9cabe42e): failed to open stream: No space left on device
Filename: drivers/Session_files_driver.php
Line Number: 159
Backtrace:
File: /home/polpe/public_html/application/controllers/Main.php
Line: 17
Function: library
File: /home/polpe/public_html/index.php
Line: 315
Function: require_once
Teljes Matlab script kiegészítő függvényekkel.
Approximate solution of the heat equation with |ode45| by considering the discretization along the spacial coordinate.
File: ccs_TG_hovezetes_PDE_megoldas_ode45.m Directory: 4_gyujtemegy/11_CCS/_1_ccs/dynamic_system_simulations Author: Peter Polcz (ppolcz@gmail.com)
Created on 2018. September 17.
$u'_t = k u''_{xx}$, where $k=1$. Initial condition: $u(x,0) = 1;
Let me discretize this equation about the spatial parameter $x$:
$$u''_{xx}[k] \simeq \frac{u[k+1] - 2 u[k] + u[k-1]}{(\Delta x)^2}$$
Therefore the PDE can be approximated by the following finite number of ordinary differential equations:
$$\pmqty{u'_t[0] \\ ... \\ u'_t[N-1]} = \pmqty{ -2 & 1 & 0 & ... & 0 \\ 1 & -2 & 1 & ... & 0 \\ ... & ... & ... & ... & ... \\ 0 & ... & 0 & -2 & 1 } \pmqty{u[0] \\ ... \\ u[N-1]}$$
Let the state vector $x$ be:
$$x = \pmqty{u[0] \\ ... \\ u[N-1]}, ~~\text{ and }~~ A = \pmqty{ -2 & 1 & 0 & ... & 0 \\ 1 & -2 & 1 & ... & 0 \\ ... & ... & ... & ... & ... \\ 0 & ... & 0 & -2 & 1 }$$
Then we have a linear autonomous system of ODEs: $\dot x = A x$. Note that matrix $A$ is a Toeplitz matrix due to its special diagonal structure.
% Nr of sample points;
N = 15;
% L = 10 meters long;
L = 10;
Dx = L / (N-1);
A = toeplitz([-2 1 zeros(1,N-2)]) / Dx^2;
B = [1 0 ; zeros(N-2,2) ; 0 1];
C = eye(N);
Cn = ctrb(A,B);
rankCn = rank(Cn)
f = @(t,x) A*x;
[t,y] = ode45(f, linspace(0,30,70), ones(N,1));
figure, surf(y)
rankCn = 15
K = lqr(A,B,10*eye(N),eye(2));
f = @(t,x) (A-B*K)*x;
[t,y] = ode45(f, linspace(0,30,70), ones(N,1));
figure, surf(y)