Can anyone help me identify what is wrong with this code

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

 Respuesta aceptada

Star Strider
Star Strider el 6 de En. de 2022
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.
.

Más respuestas (0)

Categorías

Más información sobre Get Started with MATLAB en Centro de ayuda y File Exchange.

Productos

Versión

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by