Plot x^2+y^2=4
Mostra commenti meno recenti
Hello, I have a little starter question about matlab. How do I plot a circle given by x^2+y^2=4?
Thank you.
Risposta accettata
Più risposte (3)
James Tursa
il 25 Feb 2020
E.g., since you know it is a circle with radius 2 centered at the origin;
ang = 0:0.01:2*pi;
x = 2*cos(ang);
y = 2*sin(ang);
plot(x,y);
1 Commento
Mohamed Lawindy
il 25 Feb 2020
hamza
il 24 Giu 2022
Modificato: Image Analyst
il 24 Giu 2022
0 voti
Plot the contour plots of the circles x^2+y^2 of radius 1,2, 1.41,1.73.
1 Commento
radii = [1, 2, 1.41, 1.73];
viscircles([zeros(4,1), zeros(4,1)], radii);
axis equal
grid on;
Another way to do this is to use the fcontour function.
f = @(x, y) x.^2+y.^2;
fcontour(f, 'LevelList', 4)
axis equal
If you want to see multiple contours, specify a non-scalar LevelList.
figure
fcontour(f, 'LevelList', 1:4:25)
axis equal
2 Commenti
And yet another way
viscircles([0,0], 2)
Steven Lord
il 24 Giu 2022
Note that viscircles is part of Image Processing Toolbox which means that not all users would have access to it.
Categorie
Scopri di più su Contour Plots in Centro assistenza e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!



