How to fill an array with the elements of a for loop?
5 views (last 30 days)
Show older comments
Juan Velasquez
on 8 Jul 2021
Commented: Juan Velasquez
on 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 Comments
Geoff Hayes
on 8 Jul 2021
Juan - do you need to use a loop? What happens if you just do
element = ll + 3;
?
Accepted Answer
More Answers (0)
See Also
Categories
Find more on Loops and Conditional Statements 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!