Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1 1 1 Here the x range is defined by a vector ranging from 1-4, and the y range is defined by a vector ranging

image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
1 1 1 Here the x range is defined by a vector ranging from 1-4, and the y range is defined by a vector ranging from 1-5. x = [1 2 3 4] and y = [1 2 3 4 5) To plot the z values that result from evaluating f(x,y), we need x and y matrices: 1 2 3 4 1 1 2 3 4 2 2 2 2 Xm = 1 2 34 and Yo 3 3 3 3 1 2 3 4 4 4 4 4 2 3 4 15 5 5 5 Write a function m-file, xymat.m, that accepts an x vector and a y vector as inputs that define a range in the x-y plane, and returns matrices similar to those shown above, the combination of which define the complete set of x-y coordinates within that range. Function syntax: [Xm, Ym] = xymat (x,y): 1 To plot a function of two variables, z = f(x,y), we need to have matrices of independent variable values for all of the (x,y) coordinate locations in the x-y plane at which the function is evaluated. That is, we need an x value and a y value for every z value. For example, consider evaluating f(x,y) over a range defined by 1 sxs 4 and 1 sys 5, at integer values of each variable, as shown below. 1syss 3 LI 24 15x54 . . Write an m-file, in which you do the following: Define x and y vectors that range from -10 to 10 with arbitrary step size. (You'll experiment with step size to see what provides the best looking plot.) Write a nested loop to evaluate the following function over the full range of the x-y plane defined by your x and y vectors. (Argument to sine function is in radians.) sina + y2 z = f(x,y) = x + y Call your xymat.m function to create x and y matrices, Xm and Ym, that can be used for creating a three-dimensional surface plot of f(x,y). Create a surface plot with the following MATLAB command: surf (Xm, Ym, 2) Adjust the step size to create a good-looking plot. Experiment with adjusting the viewing angle using the following command: view (azimuth, elevation) When f(x,y) is evaluated at (0,0) the function is undefined, resulting in NaN and a hole in the surface plot at the origin. Try to eliminate that hole by setting f(0,0) = 1 in your code. . . . In this problem you will write a new m-file, ENGR112_Lab8_3.m, which evaluate the same function of two variables and generates the same plot of the results. (Start by coping ENGR112_Lab8_2.m over to a new file). Now, instead of evaluating f(x,y) in a nested loop, you will write an anonymous function that can operate on the Xm and Ym matrices directly. Your m-file should do the following: Define x and y vectors that range from -10 to 10 with a step size determined in problem 2. Define an anonymous function, f, for f(x,y), using array operators (i.e. . *, ./. . ) so that it can operate on your Xm and Ym matrices in an element-by-element fashion. Call your xymat.m function to create x and y matrices, Xm and Ym. These will be used both for evaluating and for plotting f(x,y). I Pass Xm and Ym to your anonymous function, creating the resulting matrix, z. . Create a surface plot of the result as you did in the previous m-file

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Oracle9i Database Administrator Implementation And Administration

Authors: Carol McCullough-Dieter

1st Edition

0619159006, 978-0619159009

More Books

Students also viewed these Databases questions

Question

Derive expressions for the rates of forward and reverse reactions?

Answered: 1 week ago

Question

Write an expression for half-life and explain it with a diagram.

Answered: 1 week ago

Question

What do you mean by underwriting of shares ?

Answered: 1 week ago

Question

Define "Rights Issue".

Answered: 1 week ago

Question

Recommend the key methods to improve service productivity.

Answered: 1 week ago