% This function corresponds to exercise 1 in sheet 1
% and has nested if statements 
% function test=func(x)
if x<-2 test=x;
else
    if  x<0    test=-2;
    else
        if x<=2
           test=x-2;
        else
   test=x^2-4;
        end
    end
end
end