How to fill an array with the elements of a for loop?

10 Ansichten (letzte 30 Tage)
Juan Velasquez
Juan Velasquez am 8 Jul. 2021
Kommentiert: Juan Velasquez am 8 Jul. 2021
Hi, i have this code, and i want to put all of the elements from the loop inside an array, can anyone help me?
ll=[1 2 3 4 5]
for c= 1:1:length(ll)
element=ll(c)+3
end
%%result==>> ll= 4 5 6 7 8
  2 Kommentare
Geoff Hayes
Geoff Hayes am 8 Jul. 2021
Juan - do you need to use a loop? What happens if you just do
element = ll + 3;
?
Juan Velasquez
Juan Velasquez am 8 Jul. 2021
yeah, because i am practicing with the for loop.

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Soniya Jain
Soniya Jain am 8 Jul. 2021
Bearbeitet: Soniya Jain am 8 Jul. 2021
Use element(c) instead

Weitere Antworten (0)

Kategorien

Mehr zu Loops and Conditional Statements finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by