フィルターのクリア

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 Center および File ExchangeLoops and Conditional Statements についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by