NSCS 344, Week 8: Concepts
Function handles
Function handles are a way of turning functions into variables. For example, let's turn the "mean" function into a function handle.
Now we can get the mean of a vector by typing
We can also assign the handle to another variable name like this
Then
We can also have more than one input to a function handle like this
fHandle = @(x, y) mean(x, y)
fHandle =
@(x,y)mean(x,y)
where the second input tells us the dimension to take the mean over