1. Matlab Basics
Home Up Quick Reference M-files Laser Printing 1. Matlab Basics 2. Sequences & Series 3. Taylor Series 4. Fields & Flows 5. ODE Models 6. Symbolic ODE 7. Systems & 2nd order 8. Numerical ODE 9. Laplace Transform

[Objectives | Exercises | Example ]

OBJECTIVES

To become acquainted with the computer lab and MATLAB by learning some simple MATLAB commands, copying output into a Word document, and printing to the local printer.

EXERCISES

1) Read pages 1--8 in Polking & Arnold. Use MATLAB to compute the following expression:

sin(cos(eln25))+100(55/7-1000tan(.23))

Record your input and your results in the word document. Do this by highlighting the relevant lines in the MATLAB command window using the mouse. Then click on 'Edit' on the menu bar and then choose 'Copy.' Now return to the word document and click on 'Edit' and then choose 'Paste'. This will paste the highlighted text in the MATLAB command window into your word document.

2) Read about plotting with MATLAB, see pages 38 -- 40 in Polking & Arnold.  By modifying the example below, plot (on the same graph) the first 200 terms in the sequences 

an= (-1)n (n3 + n)/(n+1)3    and   bn= sin(n3).

Paste your picture into a word file. Do this by clicking on 'Edit' on the menu bar and then choosing 'Copy.' Now return to the word document and click on 'Edit' and then choose 'Paste.' This will paste the picture into the document.

Hints: 
You may find it helpful to cut text from this document and paste it back into the MATLAB command window. 
Be very careful to use the "dot" arithmetic operations in problem 2. These are needed when you are working with arrays or lists of numbers. 

EXAMPLE
Suppose that you would like to plot the first 100 terms in the sequences 

an= ncos(n)/(n2+1)  and   bn= (.99)n/3.

This can be accomplished with the following commands:

EDUğ n=1:1:100;
EDUğ a=n.*cos(n)./(n.^2+1);
EDUğ b=(.99).^n/3;
EDUğ plot(n,a,'bx',n,b,'r.'),shg
EDUğ title('The Example: plots of a_n (the x''s) and b_n (the dots)')

 

The resulting graph is 

 

To learn more about the plot command, type the command:

EDUğ help plot

Remark, the following commands would have worked as well to make the above plot.

EDUğ n=1:1:100;
EDUğ a=n.*cos(n)./(n.^2+1);
EDUğ b=(.99).^n/3;
EDUğ plot(n,a,'bx'),shg
EDUğ hold on                      % (This keeps the previous graph from being erased.)
EDUğ plot(n,b,'r.'),shg
EDUğ title('The Example: plots of a_n (the x''s) and b_n (the dots)')

[Objectives | Exercises | Example ]

 

Jump to Bruce Driver's Homepage.                       Jump to Current Courses Page.

Last modified on October 05, 1999 at 10:42 AM.