Writing a loop "for"
古いコメントを表示
Hey, i have a problem with writing a loop, which will be able to do this:
phi(1)=a_locs(1)/((a_odd(1)));
phi(2)=a_locs(2)/((a_odd(1)));
phi(3)=a_locs(3)/((a_odd(1)));
phi(4)=a_locs(4)/((a_odd(1)));
phi(5)=(a_locs(5)-a_odd(1))/((a_odd(2)));
phi(6)=(a_locs(6)-a_odd(1))/((a_odd(2)));
phi(7)=(a_locs(7)-a_odd(1))/((a_odd(2)));
phi(8)=(a_locs(8)-a_odd(1))/((a_odd(2)));
phi(9)=(a_locs(10)-(a_odd(1)+a_odd(2)))/((a_odd(3)));
phi(10)=(a_locs(11)-(a_odd(1)+a_odd(2)))/((a_odd(3)));
Someone can help me?
7 件のコメント
James Tursa
2015 年 4 月 3 日
編集済み: James Tursa
2015 年 4 月 3 日
Why do you want a loop? Is your real problem actually bigger than this? Is everything shown variables, or are some of them functions?
Michael Monka
2015 年 4 月 3 日
James Tursa
2015 年 4 月 3 日
So what are the sizes of the variables involved, and can you be more explicit in the pattern of the calculations for these larger sizes?
Image Analyst
2015 年 4 月 3 日
The thing I can't figure out is why a_locs(9) is totally missing from any of the right hand side expressions. And there are not enough equations to figure out which elements need to be "skipped" in the other equations, and what equations the "skipping" would happen at.
Stephen23
2015 年 4 月 3 日
It seems like this might be able to be written using vectorized code, thus avoiding any loops... but it would be nice to know the general algorithm here.
Michael Monka
2015 年 4 月 3 日
Jan
2015 年 4 月 3 日
@Michael: It looks like phi consists of blocks of the length 4. But 450 is not evenly divisable by 4?
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および 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!