I\'ve written the function:
function [sum] = func(a,b) sum = 0; for i = 0:b sum = sum + ((a.^i)/(factorial(i))); end
In the console, the co
Well, if you don't index sum with i, you return a single value.
sum
i
Try instead:
function [sum] = func(a,b) % Pre-allocate sum at the right size sum = NaN(1,b+1); % Compute for i = 0:b sum(i+1) = sum(i+1) + ((a.^i)/(factorial(i))); end
Best,