How to go through each element of a vector without a for loop
조회 수: 25 (최근 30일)
이전 댓글 표시
Jesus Alejandro Rodriguez Morales
2020년 9월 18일
댓글: Jesus Alejandro Rodriguez Morales
2020년 9월 18일
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
채택된 답변
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!