How to go through each element of a vector without a for loop
24 views (last 30 days)
Show older comments
Jesus Alejandro Rodriguez Morales
on 18 Sep 2020
Commented: Jesus Alejandro Rodriguez Morales
on 18 Sep 2020
I would like to write the following code without a for loop. Thanks in advance!
function fh = poly_fun(p)
function polynomial = poly(x)
polynomial = 0;
for ii = 1:length(p)
polynomial = polynomial + p(ii) .* x.^(ii-1);
end
end
fh = @poly;
end
0 Comments
Accepted Answer
More Answers (0)
See Also
Categories
Find more on Polynomials in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!