How to use surf to plot sphere function in matlab

14 views (last 30 days)
Atinesh Singh
Atinesh Singh on 6 Sep 2016
Answered: KSSV on 6 Sep 2016
I'm trying to plot sphere function below, But I'm getting wrong result
Here is the code I'm using
x1 = [-10:1:10];
x2 = [-10:1:10];
y = zeros(1,21);
for i = 1:21
y(i) = sphere([x1(i) x2(i)]);
Y = meshgrid(y);
colormap hsv;
function [y] = sphere(x)
d = length(x);
sum = 0;
for i = 1:d
sum = sum + x(i)^2;
y = sum;
Walter Roberson
Walter Roberson on 6 Sep 2016
This question appears to duplicate . Please explain the difference between the questions, other than the fact that you posted code here.

Sign in to comment.

Accepted Answer

KSSV on 6 Sep 2016

More Answers (0)

Community Treasure Hunt

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

Start Hunting!

Translated by