To create a function with loop in Matlab that takes one input and produces one output, use the following syntax:
main.m138 chars9 lines
This example function takes an input as a vector, initializes the output to zero, and then loops over the input vector elements, adding each element to the output. The resulting output is returned by the function. This is just an example, and you can replace the loop with any other algorithm depending on your task.
gistlibby LogSnag