2010. 3. 8. 22:31
[MATLAB] Euler's Method
2010. 3. 8. 22:31 in
공부이야기/MATLAB 깔짝
\begin{align*}
H(s) = \frac{1}{s+1},\quad y(0) = 0,\quad u(t) = 1
\end{align*}
인 경우 Euler's Method를 이용한 y의 근사화
\begin{align*} y[n+1] = (1-T)y[n] + Tu[n] \end{align*}
clear all; clf
T = 0.3; End = 3;
k = 0:T:End;
t = 0:0.01:End;
y = zeros(1,length(k));
for n = 1:length(k)-1
y(n+1) = (1-T)*y(n) + T*1;
end
yc = 1 - exp(-t);
subplot(211)
plot(k,y,'o'); hold on;
plot(t,yc);
\begin{align*} y[n+1] = (1-T)y[n] + Tu[n] \end{align*}
clear all; clf
T = 0.3; End = 3;
k = 0:T:End;
t = 0:0.01:End;
y = zeros(1,length(k));
for n = 1:length(k)-1
y(n+1) = (1-T)*y(n) + T*1;
end
yc = 1 - exp(-t);
subplot(211)
plot(k,y,'o'); hold on;
plot(t,yc);