# How to plot level curves of f(x,y) = 2x^2 + 5y^2. f(x,y) = c for c = 1,2,3,4,5,6

336 visualizzazioni (ultimi 30 giorni)
Carlos Perez il 10 Apr 2018
Commentato: Grace Nowak il 6 Set 2020
I have never used matlab before and have no idea how to plot level curves. I looked online and most results involve using contour but not exactly sure how to specify the upper limit of z.
##### 0 CommentiMostra -2 commenti meno recentiNascondi -2 commenti meno recenti

Accedi per commentare.

### Risposte (2)

Birdman il 10 Apr 2018
Modificato: Birdman il 10 Apr 2018
Check the output of this code:
f=@(x,y) 2*x.^2 + 5*y.^2;
[X,Y]=meshgrid(-2:0.001:2);
z=f(X,Y);
contour(X,Y,z,[1:6])
##### 0 CommentiMostra -2 commenti meno recentiNascondi -2 commenti meno recenti

Accedi per commentare.

Roger Stafford il 10 Apr 2018
Modificato: Roger Stafford il 10 Apr 2018
Your "level" curves are all ellipses and can most easily be generated by:
t = linspace(0,2*pi);
x = sqrt(c/2)*cos(t);
y = sqrt(c/5)*sin(t);
plot(x,y)
axis equal
##### 1 CommentoMostra -1 commenti meno recentiNascondi -1 commenti meno recenti
Grace Nowak il 6 Set 2020
what is c ?

Accedi per commentare.

### Categorie

Scopri di più su 2-D and 3-D Plots in Help Center e File Exchange

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by