====== Differences ====== This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
gibson:teaching:fall-2012:math445:pf1-solns [2012/12/11 14:19] gibson |
gibson:teaching:fall-2012:math445:pf1-solns [2012/12/11 14:22] (current) gibson |
||
---|---|---|---|
Line 231: | Line 231: | ||
</latex> | </latex> | ||
- | So $dx/dt = [x_2, -g - \mu x_2 |x_2|]$ | + | So $dx/dt = [x_2, ~-g - \mu x_2 |x_2|]$ |
Line 239: | Line 239: | ||
from the initial conditions $x(0) = [y(0), ~v_y(0)] = [0, 0]$. | from the initial conditions $x(0) = [y(0), ~v_y(0)] = [0, 0]$. | ||
+ | <code> | ||
g = 9.81; | g = 9.81; | ||
mu = 0.35; | mu = 0.35; | ||
f = @(x) [x(2) ; -g - mu*x(2)*abs(x(2)]; | f = @(x) [x(2) ; -g - mu*x(2)*abs(x(2)]; | ||
- | [t, x] = ode45(f, 0:100, [0 ; 0]); | + | [t, X] = ode45(f, 0:100, [0 ; 0]); |
+ | </code> | ||
Line 250: | Line 251: | ||
Label the axes. | Label the axes. | ||
- | plot(t, x(:,1)) % first column of x is 1st component of x as a function of time | + | plot(t, X(:,1)) % first column of returned X is 1st component of x as a function of time |
xlabel('t') | xlabel('t') | ||
ylabel('y = height of ball') | ylabel('y = height of ball') | ||
Line 277: | Line 278: | ||
of A. | of A. | ||
+ | <code> | ||
function y = sparse_matvec_mult(A,x) | function y = sparse_matvec_mult(A,x) | ||
K = nnz(A); | K = nnz(A); | ||
Line 288: | Line 290: | ||
end | end | ||
end | end | ||
+ | </code> |