I can't figure out this matlab function that returns the exponential of each element

1 view (last 30 days)

Answers (1)

David Hill
David Hill on 21 Sep 2019
function ex = seriesExp(x)
i=0:9;
ex=arrayfun(@(x)sum(x.^i./factorial(i)),x);
end
  2 Comments
David Hill
David Hill on 21 Sep 2019
If you have to have the for loop, then
function ex = seriesExp(x)
ex=zeros(size(x));
i=0:9;
for j=1:length(x)
ex(j)=sum(x(j).^i./factorial(i));
end
end

Sign in to comment.

Categories

Find more on MATLAB in Help Center and File Exchange

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!