Parameter sweep without nested for loop
古いコメントを表示
The following parameter sweep has many nested loops. How can I eliminate the nested loops with linear indices, but be able to access the evaporation value afterward for parameter values of temperature=75, humidity=40, and windSpeed=5? (The arithmetic line is a placeholder for a more complex calculation, so I don't want to elimate loops entirely). I know there are existing examples but I am struggling with the basics.
temperature = 70:5:90;
humidity = 30:10:100;
windSpeed = [2 5 10 20];
for iT = 1:length(temperature)
for iH = 1:length(humidity)
for iW = 1:length(windSpeed)
% Simple arithmetic placeholder for a more complex function
evaporation(iT, iH, iW) = temperature(iT) + humidity(iH) - windSpeed(iW);
end
end
end
% Access evaporation for temperature=75, humidity=40, and windSpeed=5
evaporation(temperature==75, humidity==40, windSpeed==5)
採用された回答
その他の回答 (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!