MATLAB Answers

Skipping 1st two calculations of a loop

조회 수: 1(최근 30일)
Prakhar Modi
Prakhar Modi 8 Jul 2019
편집: dpb 8 Jul 2019
hi everyone,
i need to write a code like
for i=1:n
for j=1:k
C(i,j)= a(i)+b(j)+c(j)
end
end
but here i have to provide a particular value of C(1,1) and C(1,2). So is there a way i can skip these two calculation and start with j=3. But do remember when i=2 I want that j should start from 1:k. Only C(1,1) and C(1,2) I have to skip.
Thanks in advance

  댓글 수: 0

로그인 to comment.

채택된 답변

dpb
dpb 8 Jul 2019
편집: dpb 8 Jul 2019
for i=1:n
for j=1:k
C(i,j)= a(i)+b(j)+c(j)
end
end
C(1,1:2)=[C11 C12]; % fixup special cases

  댓글 수: 2

Prakhar Modi
Prakhar Modi 8 Jul 2019
thank you
dpb
dpb 8 Jul 2019
Sometimes the answer is too obvious... :)

로그인 to comment.

추가 답변(0개)

이 질문에 답변하려면 로그인을(를) 수행하십시오.

태그

제품


릴리스

R2018a

Translated by