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

1 visualizzazione (ultimi 30 giorni)

Risposte (1)

David Hill
David Hill il 21 Set 2019
function ex = seriesExp(x)
i=0:9;
ex=arrayfun(@(x)sum(x.^i./factorial(i)),x);
end
  2 Commenti
David Hill
David Hill il 21 Set 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

Accedi per commentare.

Categorie

Scopri di più su MATLAB in Help Center e File Exchange

Prodotti

Community Treasure Hunt

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

Start Hunting!

Translated by