MATH 241: MATLAB Problem Set 1 - Plots of Functions and Shapes, Assignments of Advanced Calculus

Instructions for creating plots of various shapes and functions using matlab in problem set 1 for math 241. It includes commands for drawing polygonal lines, rectangles, circles, and graphs of functions. It also covers techniques for making the plots smoother and adjusting axes.

Typology: Assignments

Pre 2010

Uploaded on 07/30/2009

koofers-user-76
koofers-user-76 🇺🇸

10 documents

1 / 2

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
1
MATH 241
MATLAB Problem Set 1
Print out the plots of each part of the following problems to hand. If you wish
to economize on the amount of paper, you may use the command subplot (page
93 of the MATLAB Companion).
The first four problems can be done on the command line, although it is useful
to put all the commands in an Mfile.
1. a) Use the command plot to draw the polygonal line in R2through the points
(1,2),(1.5,3),(2,2),(π, 4).
b) Draw the rectangle with vertices (1,1),(4,1),(4,3),(1,3). Be sure to close
the rectangle by drawing the fourth side. To make the drawn rectangle sit inside
a larger rectangle, we set the limits of the xand yaxes with the command
>> axis([0, 5, 0,4]).
2. Graph the function
f(x) = cos x
1 + x2
on the interval [0,2π].
a) Use the commands
>> x = linspace(0, 2*pi, 11);
>> y = cos(x)./(1+x.^2);
>> plot(x,y)
The result should be a polygonal line through the 11 points (xj, f(xj)), where
xj= (2πj)/10, j = 0,1,...,10.
b) Do this in a different way with the commands
>> f = inline(’cos(x)./(1+x.^2)’)
>> plot(x,f(x))
c) To make a smoother curve, increase the number of points.
>> x = linspace(0, 2*pi, 21);
>> plot(x,f(x))
>> x = linspace(0, 2*pi, 51);
>> plot(x,f(x))
3. a) Draw the circle with center at (1,2) and radius r= 3/2 with commands
pf2

Partial preview of the text

Download MATH 241: MATLAB Problem Set 1 - Plots of Functions and Shapes and more Assignments Advanced Calculus in PDF only on Docsity!

MATH 241

MATLAB Problem Set 1

Print out the plots of each part of the following problems to hand. If you wish to economize on the amount of paper, you may use the command subplot (page 93 of the MATLAB Companion).

The first four problems can be done on the command line, although it is useful to put all the commands in an Mfile.

  1. a) Use the command plot to draw the polygonal line in R^2 through the points (1, 2), (1. 5 , 3), (2, 2), (π, 4). b) Draw the rectangle with vertices (1, 1), (4, 1), (4, 3), (1, 3). Be sure to close the rectangle by drawing the fourth side. To make the drawn rectangle sit inside a larger rectangle, we set the limits of the x and y axes with the command

axis([0, 5, 0,4]).

  1. Graph the function

f (x) =

cos x 1 + x^2

on the interval [0, 2 π]. a) Use the commands

x = linspace(0, 2*pi, 11); y = cos(x)./(1+x.^2); plot(x,y)

The result should be a polygonal line through the 11 points (xj , f (xj )), where xj = (2πj)/ 10 , j = 0, 1 ,... , 10. b) Do this in a different way with the commands

f = inline(’cos(x)./(1+x.^2)’) plot(x,f(x))

c) To make a smoother curve, increase the number of points.

x = linspace(0, 2pi, 21); plot(x,f(x)) x = linspace(0, 2pi, 51); plot(x,f(x))

  1. a) Draw the circle with center at (1, 2) and radius r = 3/2 with commands

t = linspace(0, 2pi, 101); x = 1+1.5cos(t); y = 2+1.5*sin(t); plot(x,y)

To make the circle look like a circle instead of an egg, use the command

axis equal. b) Use the command hold on. Then by changing the number of t points, draw the hexagon in this circle.

  1. a) Let S be the triangle in the xy plane, S = {(x, y) : 0 ≤ x ≤ 2 , 0 ≤ y ≤ x}. Let T be the triangular piece of surface in R^3 that is the part of the plane z = 2 x + 3y that lies over S. Draw the polygonal lines that form the boundary of S (a triangle in the xy plane). In the same figure, draw the polygonal lines that form the boundary of T ( a triangle in xyz space ) using the command hold on. b) Plot the great circles C 1 and C 2 of radius one in the same figure using hold on. C 1 is intersection of the xz plane with the sphere of radius one, and C 2 is the intersection of the vertical plane x = y with the same sphere.
  2. Write a script Mfile with a for loop that plots the graphs on the interval [0, 5] of the functions

fn(x) =

1 + xn

for n = 1,... , 10. Use the command hold on to put all the graphs in the same figure.