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 ≤...
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...
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.
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.
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
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.
Using Matlab to solve the problem below Given X=[-2 -1 0 1 2] Y=[1.5 3.2 4.5...
Using Matlab to solve the problem below Given X=[-2 -1 0 1 2] Y=[1.5 3.2 4.5 3.4 2] a). Plot a scatter plot of the data b). Determine the coefficients of the polynomial ?0 + ?1? + ?2?2 which best fits the data c). Plot this function on the same plot as in part ‘a’. USE MATLAB CODE ONLY! USE MATLAB CODE ONLY! THANK YOU
sketch a contour diagram for the function f(x,y)=x-y^2 with at least four labeled contours
sketch a contour diagram for the function f(x,y)=x-y^2 with at least four labeled contours
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT