function l =pol3(arr)
arr = [5 10 15 20 25 30 35 40];
for i=1:length(arr)
diff(i) = arr(i+1) - arr(i) %I keep getting an error on line 4
end

 채택된 답변

Star Strider
Star Strider 2022년 1월 6일

1 개 추천

Try this instead —
for i=2:length(arr)
diff(i) = arr(i) - arr(i-1) %I keep getting an error on line 4
end
Be sure that ‘diff’ — not ‘l’ — is defined as the output.
.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Get Started with MATLAB에 대해 자세히 알아보기

제품

릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by