Plot z = x^2 + y^2 over the interval -4 <= x <= +4, -4 <= y <= +4.
57 views (last 30 days)
Show older comments
I'm not sure how to plot above equation. Can anyone help me?
0 Comments
Accepted Answer
KSSV
on 14 Sep 2018
N = 100 ;
x = linspace(-4,4,N) ;
y = linspace(-4,4,N) ;
[X,Y] = meshgrid(x,y) ;
Z = X.^2+Y.^2 ;
surf(X,Y,Z)
4 Comments
Image Analyst
on 14 Sep 2018
Correct, but don't do more than you can see any difference for. Yours is such a smooth function it doesn't make sense to do many more points. If you do, the edge lines will ruin the colors.
You can turn off the black edge lines like this:
surf(X,Y,Z, 'EdgeColor', 'none')
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!