How can I store the output data from a for loop

pwf=[0 500 1000 1500 2000 2500 ];
for pwf=[0 500 1000 1500 2000 2500 ]
flow(pwf)=qmax*(1-0.2*(pwf/r)-0.8*(pwf/r)^2);
end
o= table(pwf,flow)
I would like to save all of the outputs and show them in a table, but I don't know how to do so.

 採用された回答

Chad Greene
Chad Greene 2017 年 3 月 12 日

0 投票

Try this:
pwf=[0 500 1000 1500 2000 2500 ];
for k = 1:length(pwf)
flow(k)=qmax*(1-0.2*(pwf(k)/r)-0.8*(pwf(k)/r)^2);
end

2 件のコメント

Mohab Ayman
Mohab Ayman 2017 年 3 月 12 日
Thanks alot Chad you really helped me :)
Chad Greene
Chad Greene 2017 年 3 月 12 日
Great, I'm glad it worked for you!

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および 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