% MT 03 2018/19 % Problem Set 2, Exercise 1 function [ Z ] = hemisphere( X,Y,R ) % hemisphere.m calculates surface points of a sphere % both for scalars, vectors and matrices % A solution for the sphere exists only % within a circle around the origin of radius R % Logical condition in a array implementation L = (X.^2 + Y.^2 < R.^2); % Initialize Z (not necessary) % Z = zeros(SX); Z = L.*sqrt(R.^2 - X.^2 -Y.^2); end