Skip to content

Instantly share code, notes, and snippets.

@gunungloli666
Created May 1, 2012 07:12
Show Gist options
  • Save gunungloli666/2565873 to your computer and use it in GitHub Desktop.
Save gunungloli666/2565873 to your computer and use it in GitHub Desktop.
n=linspace(-4,4,30);
[X,Y]=meshgrid(n,n);
p=length(X);
q=length(Y);
Z = X.^2+2*Y-2*X;
surf(X,Y,Z);
hold on;
view(30,3);
% Mengambil data secara acak dari permukaan tadi.
R=(rand(p,q)>.7);
aa=find(R);
cc=length(aa);
M=zeros(cc,3);
h=1; %untuk iterasi element dari M
for i=1:p,
for j=1:q,
if R(i,j)
M(h,1)=X(i,j);
M(h,2)=Y(i,j);
M(h,3)=Z(i,j);
h=h+1;
end
end
end
stem3(M(:,1), M(:,2), M(:,3)+4, 'filled');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment