필터 지우기
필터 지우기

could anyone help me to solve the issue for the following code.

조회 수: 2 (최근 30일)
jaah navi
jaah navi 2019년 4월 16일
댓글: Stephen23 2019년 4월 16일
code:
i=1:3
for j=1:length(i)
j=j+1
end
the code excutes and give the output j = 2
j = 3
j = 4
could anyone help how to add all the values (j=2+3+4)after for loop.

답변 (1개)

KSSV
KSSV 2019년 4월 16일
편집: KSSV 2019년 4월 16일
Why you want to use a loop?
i = 1:3 ;
iwant = sum(i+1)
  댓글 수: 2
jaah navi
jaah navi 2019년 4월 16일
that is just the sample,I just gave with an example.
In my code i need to add up all the values generated by using formula after for loop each time.
Torsten
Torsten 2019년 4월 16일
i=1:3;
jj=0;
for j=1:length(i)
j=j+1;
jj=jj+j;
end
jj

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

카테고리

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