Fixing a for loop that's 90% correct

2 ビュー (過去 30 日間)
Cary
Cary 2015 年 8 月 21 日
コメント済み: Walter Roberson 2015 年 8 月 21 日
On the first pass through k, everything is fine. But when k=2, x=2, so my subscript index is starting with 2, not 1. If I change 'for x = k:ssLength(k)' to 'for 1 = k:ssLength(k)', then the loop starts at 1 on each iteration, but doing this overwrites the data in the cell, instead of appending to it.
i=2:91;
j=9:97;
for k = 1:length(matrix)
for x = k:ssLength(k)
m1(i(k),j(x))=-mid(shortStrikeIdx{1,k}(x))+mid(longStrikeIdx{1,k}(x));
end
end
  1 件のコメント
Walter Roberson
Walter Roberson 2015 年 8 月 21 日
?? That codes does not write to any cell and does not append to any cell, so I do not understand your description.

サインインしてコメントする。

回答 (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