Question

Write a MATLAB code to plot a contour graph of f(x, y) = x^2 + y^2...

Write a MATLAB code to plot a contour graph of f(x, y) = x^2 + y^2 for −2 ≤ x ≤ 2 and −3 ≤ y ≤ 3. Use the interval of 0.1 in the grid.

Homework Answers

Answer #1

clc;clear all
x=-2:0.1:2;      %creating a x vector with 0.1 space

y=-3:0.1:3;      %creating a y vector with 0.1 space
[X Y]=meshgrid(x,y);    % this gives meshgrid for the contour plot
A=X.^2+Y.^2;    %Assigning the Value of f(X,Y) to A
contour(X,Y,A) %gives the contour plot
xlabel('X');ylabel('Y');alabel('A')         %attaching labels to the axis
title('Contour plot f(x,y)=x^{2}+y^{2}')

Know the answer?
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
Similar Questions
Using for loop and if statement, write a MATLAB code to plot a graph for x(t)...
Using for loop and if statement, write a MATLAB code to plot a graph for x(t) as a function of time t in the range 0 to 12 in increment of 0.01 ?(?) = 1: 0 ≤ ? ≤ 1 2? − 1 1 ≤ ? ≤ 2 3 2 ≤ ? ≤ 3 −2.5? + 10.5 3 ≤ ? ≤ 5 −2 5 ≤ ? ≤ 6 4/3 ? − 10 6 ≤ ? ≤ 9 2 9 ≤...
Write a MATLAB m file to plot the 3-D curve represented by a multivariable function z(x,y)...
Write a MATLAB m file to plot the 3-D curve represented by a multivariable function z(x,y) = x2 −0.5y2 over x ∈ [−2,2] and y ∈ [−2,2]. Use a 2 point thickness. For both x an y axes, choose the grid size to be 0.05. Clearly label and title your plot. Rotate the view at an azymuth of −20 , and elevation of 20 . You need to use the following commands: x=-2:0.05:2; y=x; z=x.^2-0.5*y.^2; plot3(x,y,z,’LineWidth’,2) label(’ My 3D curve’);...
4. Consider the function z = f(x, y) = x^(2) + 4y^(2) (a) Describe the contour...
4. Consider the function z = f(x, y) = x^(2) + 4y^(2) (a) Describe the contour corresponding to z = 1. (b) Write down the equation of the curve obtained as the intersection of the graph of z and the plane x = 1. (c) Write down the equation of the curve obtained as the intersection of the graph of z and the plane y = 1. (d) Write down the point of intersection of the curves in (b) and...
draw a contour plot for h(x,y)=2x^2-y-2. show work.
draw a contour plot for h(x,y)=2x^2-y-2. show work.
In MATLAB, generate a 3D plot as follows: Create 2 vectors x and y, both ranging...
In MATLAB, generate a 3D plot as follows: Create 2 vectors x and y, both ranging from -5 to 5 with interval of 0.05 using linspace or colon operator. Generate grid of values X and Y using the vectors x and y. Define the variable Z as follows: Z = 2X3 + 4Y2 + 7 +sinX3 + Y2 Generate a surface and a mesh plot with the variables X,Y,Z. Show your plots.
Write a Matlab program to plot the cosine wave. That is plot y=cos(k1x) vs. x for...
Write a Matlab program to plot the cosine wave. That is plot y=cos(k1x) vs. x for x varying from 0 to 2pi radians. The value of k1 is given at the end of this document. You can choose the increment for x. Note that large values of the increment will give you a coarse graph. Note: Matlab has two functions to calculate the sine of an angle: sin(x) and sind(x). What is the difference between these two functions? Use help...
Draw a contour map for the surface f(x,y)=16-x^2-y^2 using the contour lines C= 0, 4,7 and...
Draw a contour map for the surface f(x,y)=16-x^2-y^2 using the contour lines C= 0, 4,7 and 16
Using MATLAB Write a user-defined MATLAB function for the following math function: y(x)= (-0.2x^3 + 7x^2)e^-0.3x...
Using MATLAB Write a user-defined MATLAB function for the following math function: y(x)= (-0.2x^3 + 7x^2)e^-0.3x The input to the function is x and the output is y. Write the function such that x can be a vector (use element-by-element operations). (a) Use the function to calculate y(-1.5) and y(5). (b) Use the function to make a plot of the function y(x) for -2 ≤ x ≤ 6.
sketch a contour plot for the joint pdf of X and Y where X~ = normal...
sketch a contour plot for the joint pdf of X and Y where X~ = normal (3,1)  independent of Y~ Normal (0,4)
Draw a contour map of the function f(x, y) = y/(2x 2 + y 2 )...
Draw a contour map of the function f(x, y) = y/(2x 2 + y 2 ) showing several level curves.
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT