Question

MATLAB

Any guidance is appreciated!

Use meshgrid() function to create 2D grid coordinates with x- and y- coordinates both from -12 to +12 in the increment 1/32. Calculate the function z shown below at every (x, y) point and store the result in a 2D array z a) b) sin(Vx2+y2) x2 +y c) Find the maximum value in array z and its corresponding index. The array may have more than one maximum points with the same maximum value, you only need to find one of them. Display your results as: The maximum occurs when x is (result) and y is (result). d) Plot the result using the plotting function mesh(x,y,z) (it looks really cool!)

0 0
Add a comment Improve this question Transcribed image text
Answer #1

%x-coordinate x=-12:0.03 : 12; %y-coordinate increment by 1/32 ys-12:0.03:12; susing meshgrid %result is stored in [X,Y]=mesh

code:

%a.
%x-coordinate
x=-12:0.03:12;
%y-coordinate
%increment by 1/32
y=-12:0.03:12;

%using meshgrid
%result is stored in a 2D array
[X,Y]=meshgrid(x,y);

%b. given equation
Z=[sin(sqrt(X.^2+Y.^2))/(sqrt(X.^2+Y.^2))];

%c
[max,index]=max(Z);

%d. using mesh to plot the results
mesh(X,Y,Z);

Add a comment
Know the answer?
Add Answer to:
MATLAB Any guidance is appreciated! Use meshgrid() function to create 2D grid coordinates with x- and...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • ON MATLAB, CREATE THOSE OUTPUTS WITH DIFFERENT VALUES. BE SURE U HAVE TO CHANGE NUMBERS, COLORS,...

    ON MATLAB, CREATE THOSE OUTPUTS WITH DIFFERENT VALUES. BE SURE U HAVE TO CHANGE NUMBERS, COLORS, SHAPES AND LTNE WEIGHTs... AND SHOW YOUR OUTPUT RESULTS AS WELL... the code:: % About Graphs x = 0: pi/40: 4*pi; figure, plot(x, sin(x)) figure, plot([1 1 2 3 3], [0 2 3 2 0]), axis([0 4 0 4]) % for easy plotting: figure, ezplot('tan(x)') % for plotting two graphs on the same axes % it allows to have independent y-axis labels on the...

  • 1) Create a matlab function that calculates: for Name your function TwoVarFunc : The inputs should...

    1) Create a matlab function that calculates: for Name your function TwoVarFunc : The inputs should be in the same order: xmin xmax ymin ymax N: n is the number of elements in the vector x and y The ouputs should be in the same order: f_xy: is the calculated array f(x,y) f_xyMAX: should be the the maximum value of the function f(x,y). Hint: to create vectors x and y look up the matlab built-in function linspace() Hint 2: To...

  • Please help with this MATLAB problem! I'm writing in MATLAB_R2018b if that makes a difference:) 7....

    Please help with this MATLAB problem! I'm writing in MATLAB_R2018b if that makes a difference:) 7. Write a Matlab function (HW07 07.m) that takes 4 arguments and returns two arrays. The arguments are the Xc and yc coordinates of the center of a circle, the radius r of the circle, and the number of points n on the circle. The function should create a list of n equally-spaced angle values ranging from 0 to 2n. Then, for each angle value,...

  • 2) Use the function h(x,y)= as follows: 1+x2+y2+x+xy 2 2D optimization utilizing Excel · Produce a...

    2) Use the function h(x,y)= as follows: 1+x2+y2+x+xy 2 2D optimization utilizing Excel · Produce a surface plot of the function Utilize Solver to find the optimum value o o 2D optimization utilizing Matlab o o o Produce a surface plot the function Produce a contour plot of the function Utilize fminsearch to find the optimum value

  • Problem 4 (programming): Create a MATLAB function named mynewton.m to estimate the root for any a...

    Problem 4 (programming): Create a MATLAB function named mynewton.m to estimate the root for any arbitrary function f given an initial guess xo, an absolute error tolerance e and a maximum number of iterations max.iter. Follow mynewton.m template posted in homework 2 folder on TritonED for guidance. You are not required to use the template. The function should return the approximated root n and the number of steps n taken to reach the solution. Use function mynewton.m to perform the...

  • MATLAB Algorithm 6 First draw a flow chart then create a function with the header [X]...

    MATLAB Algorithm 6 First draw a flow chart then create a function with the header [X] - lowest (A) that will find the lowest value of the array A and output the value in X. This function should work for an array A of any length Hint: the length() function may be of use Rules you cannot use the MATLAB sort() function and you cannot use the max(), min( ), maxk or mink functions Check your function [X] -lowest([19, 24,...

  • 1. (25 pts) Given the following start for a Matlab function: function [answer] = NewtonForm(m,x,y,z) that inputs • number of data points m; • vectors x and y, both with m components, holding x- and y-...

    1. (25 pts) Given the following start for a Matlab function: function [answer] = NewtonForm(m,x,y,z) that inputs • number of data points m; • vectors x and y, both with m components, holding x- and y-coordinates, respectively, of data points; • location z; and uses divided difference tables and Newton form to output the value of the Lagrange polynomial, interpolating the data points, at z. 1. (25 pts) Given the following start for a Matlab function: function [answer] NewtonForm(m.x.yz) that...

  • Matlab! Use Matlab to calculate array X and array Y. The first column is time (1,...

    Matlab! Use Matlab to calculate array X and array Y. The first column is time (1, 2, 3 ...), and the second column is value (0 and 1). When the value of array X is 0, the value of array Y is itself at the same time. When the value of array X is 1, the value of array Y will become the value of the previous Y(i-1) The data of the array is given, just how to change the...

  • I need to create a MATLAB function, bvp_solve.m, to approximate the solution y(x). The function takes...

    I need to create a MATLAB function, bvp_solve.m, to approximate the solution y(x). The function takes the number of grid points n as an input. The outputs are grid vector x and the solution vector y %% This is the function i have so far: function [xi, yi] = bvp_solve(n) % BVP_SOLVE computes the solution y(x) of a two-point boundary value problem % using finite difference method (FDM). % The governing equation is % y''' = -y + (x -...

  • 3. (3 points) Write the sequence of MATLAB commands that you would use to produce a...

    3. (3 points) Write the sequence of MATLAB commands that you would use to produce a plot depicting the rotini-like surface defined by: for radii (r) going from 0 to 1 (21 values) and angles (θ) going from-10π to 10π (501 values). Your sequence of commands should define rectangular grids of radii and angles, transform them to cartesian coordinates (x.y), compute z, and plot the result as a solid surface, without gridlines (use shading command), with equally scaled x, y...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT