Assume I have a collection A:
A = [0:6:100]
And I have a function fib(n):
function retval=fib(n)
g1=(1+5^.5)/2
g2=(1-5^.5)/2
retval=(1/5^.5)*(g1^n - g2^n)
endfunction
I intend to be able to apply fib(n) on A, and store it in a collection say B, where B[i,j] is (i,fib(i)), so I can plot i vs fib(i) and see the results on a graph.
Please advise on how I can use map to obtain this desired collection B.
You can do it like this:
The
@makesfibinto a function handle. Note thatmapis being deprecated and you should usearrayfuninstead: