필터 지우기
필터 지우기

Code for Plotting Sphere function

조회 수: 9 (최근 30일)
Atinesh Singh
Atinesh Singh 2016년 9월 4일
댓글: Atinesh Singh 2016년 9월 5일
Can anybody share the complete code for plotting sphere function
like this
in matlab

채택된 답변

John BG
John BG 2016년 9월 5일
Atinesh, 4 steps
1. define the [x y] grid:
x=[-10:1:10];y=[-10:1:10];
2. build all possible points, there are other ways but this is the most compact one
[X,Y]=meshgrid(x,y);
3. Calculate the function points
Z=X.^2+Y.^2;
4. 3D plot with surf
surf(Z)
Atesh,
if you find this answer useful would you please be so kind to mark my answer as Accepted Answer?
To any other reader, please if you find this answer of any help solving your question,
please click on the thumbs-up vote link,
thanks in advance
John BG
  댓글 수: 1
Atinesh Singh
Atinesh Singh 2016년 9월 5일
Can you help me with Rastrigin function
I'm using this code (Step 3), But it is producing Sphere function
Z = (X.^2 - 10*cos(2*pi*X) + 10) + (Y.^2 - 10*cos(2*pi*Y) + 10);

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

추가 답변 (0개)

카테고리

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