I can't figure out this matlab function that returns the exponential of each element
1 view (last 30 days)
Show older comments
0 Comments
Answers (1)
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
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
See Also
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!