15.11.2014 Views

MATLAB Mathematics - SERC - Index of

MATLAB Mathematics - SERC - Index of

MATLAB Mathematics - SERC - Index of

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Boundary Value Problems for ODEs<br />

6 View the results. Complete the example by displaying the results:<br />

a Print the value <strong>of</strong> the unknown parameter λ found by bvp4c.<br />

fprintf('The fourth eigenvalue is approximately %7.3f.\n',...<br />

sol.parameters)<br />

b<br />

Use deval to evaluate the numerical solution at 100 equally spaced<br />

points in the interval [ 0,<br />

π]<br />

, and plot its first component. This component<br />

approximates yx ( ).<br />

xint = linspace(0,pi);<br />

Sxint = deval(sol,xint);<br />

plot(xint,Sxint(1,:))<br />

axis([0 pi -1 1.1])<br />

title('Eigenfunction <strong>of</strong> Mathieu''s equation.')<br />

xlabel('x')<br />

ylabel('solution y')<br />

See “Evaluating the Solution at Specific Points” on page 5-72 for<br />

information about using deval.<br />

The following plot shows the eigenfunction associated with the final<br />

eigenvalue λ = 17.097.<br />

solution y<br />

1<br />

0.8<br />

0.6<br />

0.4<br />

0.2<br />

0<br />

−0.2<br />

−0.4<br />

−0.6<br />

−0.8<br />

Eigenfunction <strong>of</strong> Mathieu’s equation.<br />

−1<br />

0 0.5 1 1.5 2 2.5 3<br />

x<br />

5-71

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!