Here's an example recursive function in Matlab that takes an array as an input and returns the product of all its elements:
main.m269 chars8 lines
You can call this function with an array like this:
main.m76 chars4 lines
This will output the product of all elements in the array arr
, which is 1 x 2 x 3 x 4 x 5 = 120.
gistlibby LogSnag