필터 지우기
필터 지우기

for loops and arrays

조회 수: 1 (최근 30일)
harley
harley 2014년 8월 25일
댓글: Star Strider 2014년 8월 25일
Hello,
part of a script below. How can i write this without typing every in c(j-1,5). I am planning on expanding the array. Thanks
for j=2:t_dom+1
cc=A\(B*[c(j-1,2);c(j-1,3);c(j-1,4);c(j-1,5);c(j-1,6);c(j-1,7);c(j-1,8)]);
for kk=1:length(cc)
c(j,kk+1)=cc(kk);
end
end

채택된 답변

Star Strider
Star Strider 2014년 8월 25일
See if this improves things:
cc=A\(B*[c(j-1,2:8)]');
This assumes c(j-1,2:8) is a row vector to start. If it is a column vector, leave off the transpose (') operator:
cc=A\(B*[c(j-1,2:8)]);
  댓글 수: 2
harley
harley 2014년 8월 25일
thanks
Star Strider
Star Strider 2014년 8월 25일
My pleasure!

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

추가 답변 (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