MATLAB: Need help with a nested for loops

nested

Hello everyone!I am trying to create a function that you can put a vector 'x' and a order 'N' to solve for the exp(x). It is close to being correct however i just can't seem to get it.
function [y] = nexp1(x,N)
U = length(x);
for k = 1:U
asum = 0;
for w = 1:length(x)
new = (x(k).^w / factorial(w))
asum = asum + new
end
y(k) = asum
end
end

Best Answer

Your
for w = 1:length(x)
Should be
for w = 0 : N
Related Question