I'm trying to do a simple speed test in Matlab. I want it to factor 3^a-2 for each a from 1 to 20. Might be I'm choosing too small numbers here to see any significant difference, but I'm stuck anyway.
I tried to write
n = [1:20]
m = 3.^n-1
arrayfun(factor,m)
this gives a "not enough input parameters" error. I though it made sense but apparently not. After looking at some examples of arrayfun and the manual, i also tried
arrayfun(@(m)factor(m), m)
arrayfun(@(m), factor(m), m)
arrayfun(@factor, m)
but none worked. What's the correct way to do it? And also if I do speed tests of this sort, will the results be cached so I will have to use different numbers if I do the test again?