looping a code efficiently
古いコメントを表示
Hi,
I am writing a loop code for a particle. The equations involved are the following:
f_1x(t) = x_1;
v_1 = w*v_1 + c_p*rand*(x_1best - x_1) + c_n*rand*(g_best - x_1);
x_1 = x_1 + v_1;
As you can see, if I add another particle, all I need to do is actually add another set of those equations, and change all 1's to 2's. They will work out to be fine.
The problem is … if I want work with 100 other particles, there is should be a better way than just copying and pasting these equations 100 times!
Please help me find out what functions/commands I need for this. You do not need to write down the code for me. I need to know what commands/functions I should be dealing with so that I can study these after.
採用された回答
その他の回答 (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!