Updating with for-loop (straightforward)
8 ビュー (過去 30 日間)
古いコメントを表示
AA =
2 8 4.........
4 9 34.........
BB =
4 5 2.........
9 23 11.........
dt = 0.1 % time step
for t = 0:dt:4
pA = AA(:, t+1)
pB = BB(:, t+1)
end
There are several other columns for AA and BB. At t = 0, I need to assign the first columns of AA and BB to pA and pB respectively. At t = 0.1, the second columns. At t = 0.2, the third columns and so on.
I know the error is in AA(:, t+1) and BB(:, t+1) because t is in decimals and column numbers cannot be in decimals. I just don't know how to rectify it.
0 件のコメント
採用された回答
David Goodmanson
2017 年 7 月 10 日
編集済み: David Goodmanson
2017 年 7 月 10 日
Hello Fiona,
One way is to use an index to address AA and BB and to calculate t. You have 41 possible values for t, so
for n = 1:41
pA = AA(:,n)
pB = BB(:,n)
t = .1*(n-1); % relationship between n and t
(possibly more calculations involving t inside the loop are here)
end
pA and pB change every time in the loop and are not being saved, so I assume you are doing some calculation with them inside the loop.
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Loops and Conditional Statements についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!