필터 지우기
필터 지우기

How to plot unit sphreres?

조회 수: 1 (최근 30일)
DerMischa
DerMischa 2017년 11월 17일
댓글: Nipun 2022년 7월 4일
Hey Guys, kind of new here so this is a noob question. I want to plot different unit spheres, meaning this equation has to be solved for the euclidean norm (n=2):
sqrt(x^2+y^2)=1
So I came up with this solution.
[X,Y] = meshgrid(linspace(-1,1));
n=2;
f = (X.^n + Y.^n).^(1/n);
contour(X,Y,f)
Unfortunatly contour plots not only the unit sphere for my euclidian norm, but also additional circles with a different radius.
How do I tell contour to only plot my unit sphere ? Is contour even the right function for this kind of problem ? Would be really nice if someone could help me out.
  댓글 수: 1
Nipun
Nipun 2022년 7월 4일
Hi DerMischa,
Yes, definitely: contour will plot all the circles (or surfaces in two-dimension) that satisfy your equation.
For plotting a unit sphere, there are some inbuilt MATLAB functionalities you may leverage: sphere , axis
An extensive guide to plotting sphere on different axis with different radi is linked here: https://in.mathworks.com/help/matlab/ref/sphere.html
Hope this helps!

댓글을 달려면 로그인하십시오.

답변 (1개)

Ashutosh Thakur
Ashutosh Thakur 2022년 6월 30일
You can create unit sphere using inbuilt matlab function
sphere
axis equal
You can follow this article to know more about sphere function.

카테고리

Help CenterFile Exchange에서 Surface and Mesh Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by