for loop over matrix expression
1 回表示 (過去 30 日間)
古いコメントを表示
Vishwarath Taduru
2017 年 9 月 24 日
回答済み: Walter Roberson
2017 年 9 月 24 日
Hi I have two entries in a block of code a=[1 2;3 4] and b=[2 4; 6 7] Now I want to execute a for loop so that the first iteration value is a and the second iteration value is b. What happening now if I write the following piece is that value of w is first column of a. No I want entire a to be w. Is there anyway I can do that?
for w=[a b]
some code
end
0 件のコメント
採用された回答
Walter Roberson
2017 年 9 月 24 日
a=[1 2;3 4]; b=[2 4; 6 7];
for wcell = {a, b};
w = wcell{1};
...
end
0 件のコメント
その他の回答 (1 件)
Image Analyst
2017 年 9 月 24 日
Then don't use a for loop. Use a function
outputa = ProcessW(a);
outputb = ProcessW(b);
function should be defined like this:
function output = ProcessW(w)
output = some manipulations based on 2-D w matrix.
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!