필터 지우기
필터 지우기

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

조회 수: 12 (최근 30일)
Juan Velasquez
Juan Velasquez 2021년 7월 8일
댓글: Juan Velasquez 2021년 7월 8일
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
Geoff Hayes
Geoff Hayes 2021년 7월 8일
Juan - do you need to use a loop? What happens if you just do
element = ll + 3;
?
Juan Velasquez
Juan Velasquez 2021년 7월 8일
yeah, because i am practicing with the for loop.

댓글을 달려면 로그인하십시오.

채택된 답변

Soniya Jain
Soniya Jain 2021년 7월 8일
편집: Soniya Jain 2021년 7월 8일
Use element(c) instead

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by