0% found this document useful (0 votes)
10 views2 pages

Matlab Project On 3d Representation of Visual Space

MATH 241 Project 2 requires students to write and publish a MATLAB script as a PDF for submission on Gradescope by April 3rd. The project involves plotting functions, computing gradients, and using Lagrange multipliers, with specific instructions on formatting and collaboration. Students are encouraged to refer to 'Justin's Guide Part 2' for guidance before starting the project problems.

Uploaded by

Soham Ojha
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views2 pages

Matlab Project On 3d Representation of Visual Space

MATH 241 Project 2 requires students to write and publish a MATLAB script as a PDF for submission on Gradescope by April 3rd. The project involves plotting functions, computing gradients, and using Lagrange multipliers, with specific instructions on formatting and collaboration. Students are encouraged to refer to 'Justin's Guide Part 2' for guidance before starting the project problems.

Uploaded by

Soham Ojha
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

MATH 241 –MATLAB Project 2 – due April 3rd, 11.59 pm.

• What to turn in: You will need to write a script (.m file) and then “publish” it in MATLAB as a
PDF in order to turn it in on Gradescope.
• What is a script? A script is just a sequence of MATLAB commands, with each command on its
own line. If you click “Run”, MATLAB will execute all of the commands in the script, in order. To
open a new script, click on ’New Script’ in the top menu bar.
• What is publishing? When you “publish” a script, MATLAB will produce a nice-looking document
that displays all of the code in your script as well as the output produced by the commands after
they were executed. As a general rule, we need to be able to see all of your commands as well
as the output produced by your commands. Do NOT end your lines of code with a semicolon
; Doing so suppresses the output of that line from appearing. Here are some other important points
about publishing.
– You may need to go into the options in MATLAB to change the format of the published document
from HTML to PDF. Please be sure to submit a PDF document. This can be done by going to
Publish → Edit Publishing Options → Output File Format.
– In the published document, MATLAB displays ALL of the commands and then ALL of the output
afterwards. For a long script, this results in something that is very difficult to read. Here is how
you separate your code problem-by-problem in order to make it better: Before each numbered
problem, type %% in the script to make a heading. This signifies to MATLAB that it is a new
portion of code, and MATLAB separates it accordingly when published. Any text after the %%
reads as a heading; remember to put a space between it and any text!
Do this Not this
%% Problem 1 %%Problem 1
After you publish, it should look like
∗ Code for Problem 1
∗ Output for Problem 1
∗ Code for Problem 2
∗ Output for Problem 2
..
∗ .
– You will need to include some answers to questions that are not MATLAB commands (e.g. you
may have to explain why something happened). These questions are marked with a ⋆, and they
require you to type an answer that is not just a MATLAB command. These answers will need to
be typed as comments in your script, which is done by typing a single % sign, followed by your
comment, like this:
% This is a comment!
This % tells MATLAB to not treat what follows as code.
• Rules for working in groups: You are encouraged to collaborate on this project. Projects may be
turned in by groups of no more than two students, and in Gradescope for group submissions, there will
be an option to include both group member’s names.

• But first: Before you begin the project, go through “Justin’s Guide Part 2” (and also Part 1 if
needed). Be sure to type along in MATLAB as you read.
The project problems begin on the next page.
0. Read ”The Justin Guide to MATLAB, Part 2’, available on ELMS.
1. (material from Chapter 13.1)
2
−y 2
(a) Plot the function f (x, y) = (x2 + y 2 )e1−x over the domain −1 ≤ x ≤ 1, −1 ≤ y ≤ 1.
(b) In a single graph, plot some level curves. (A good choice of levels might be c = 0, 1, 2, ....) [Note:
Instead of using a separate plot command for each curve, you can consider reading the MATLAB
documentation for the functions contour or ezcontour and using one of these to plot the level
curves. These two commands do not appear in the “Justin guide”.]
2. (material from Chapter 13.6)
(a) Plot the function f (x, y) = y sin(xy) − x sin(3x).
(b) Compute the gradient of f in MATLAB using the jacobian function.
(c) If we are on the surface of f when (x, y) = (1, 1), in which direction should we walk so that our
vertical height increases most rapidly?
3. (material from Chapter 13.8)

(a) Plot the function f (x, y) = 2y 3 x − x2 − 3xy. How many maximum and minimum points do you
expect f has? How many saddle points?
(b) Find fx and fy using the diff command. Setting these to zero, solve the resulting system of
equations using the solve command. How many critical points do you obtain?
(c) Compute the matrix of second partial derivatives and use it to determine whether f has a relative
minimum, relative maximum, or saddle point at each critical point. If the test is inconclusive,
you will need to look at the graph to make a conclusion about the nature of the critical points.
4. (Can be solved after reading Chapter 13.9) Use Lagrange multipliers to solve the following problem.
All the computations are to be done in MATLAB.
Suppose a new planet has been discovered and we’d like to find the point on the planet where the
magnetic field is weakest. The planet is perfectly spherically shaped with radius 3 ( units that don’t
matter), and taking the center of the planet as the origin of our coordinate system, the strength of the
magnetic field at a point (x, y, z) is approximated by M (x, y, z) = xy − z 2 + 3x + 3. Find the point(s)
on the surface of the planet where M is minimal (i.e. the magnetic field is weakest).

You might also like