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

208 次查看(过去 30 天)
Carlos Perez
Carlos Perez2018-4-10
评论: Grace Nowak ,2020-9-6
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.

回答(2 个)

Birdman 2018-4-10
编辑:Birdman 2018-4-10
Check the output of this code:
f=@(x,y) 2*x.^2 + 5*y.^2;

Roger Stafford
Roger Stafford 2018-4-10
编辑:Roger Stafford 2018-4-10
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);
axis equal

Community Treasure Hunt

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

Start Hunting!

Translated by