2010. 3. 9. 14:19
[MATLAB] Euler's Method second order case
2010. 3. 9. 14:19 in
공부이야기/MATLAB 깔짝
\begin{align*}
y'' + 2y' + y = \sin (t),\quad y(0) = 0,\quad y'(0) = 0
\end{align*}
clear all;
T = 0.2;
n = 0:T:8;
y = zeros(1,length(n));
clear all;
T = 0.2;
n = 0:T:8;
y = zeros(1,length(n));
for k = 1:length(y)-2
y(k+2) = (2-2*T)*y(k+1) + (2*T-1-T^2)*y(k) + T^2*sin(k*T);
end
num = 1;
den = conv([1 2 1],[1 0 1]);
impulse(num,den); hold on;
axis([0 8 -1 1]); grid on;
plot(n,y,'o')