%%Anonymous Functions

%Can be annoying to have to make a new file for a simple function

%Work by creating a function handle without giving a name to a function
%that is already defined
%Should only use this for very simple functions (preferably only 1 input
%argument)

%Examples:
quadHandle1 = @(x)3*x.^2+2.*x-2;
disp(quadHandle1(2))
quadHandle2 = @(p)(p-1).^2;
disp(quadHandle2(1))
anonymousTrigFunction = @(x)2*sin(x)-cos(x).^2;
disp(anonymousTrigFunction([1,pi]))
disp(aTrigFunction([1,pi]))

%Example: Add Noise
xx = 5 : 0.001 : 10;
yy = polyval([0.1,1, 5], xx);
noise1 = addNoise(yy,@(x)sin(x));
noise2 = addNoise(yy,anonymousTrigFunction);
plot(xx,yy,xx,noise1,xx,noise2)




