While loop word problem
16 ビュー (過去 30 日間)
古いコメントを表示
I have the following word problem and am struggling to determine the arguments for the while loop. Any information is helpful!
Write a while loop that outputs the answer to the following question: Sally prepares two plates of 10 cells each. One plate has normal cells, and the other contains cells with a mutation believed to reduce the normal hourly reproduction rate by half. If the number of normal cells triples every hour, how many of each type of cell should be in the plates after 12 hours? Name the outputs total_normal and total_mutant.
2 件のコメント
採用された回答
Jon
2020 年 9 月 30 日
You will need to add the details but you probably want to do something like this
% set some parameters
runHours = 12; % number of hours to run test for
normalRate = 3;
mutantRate = normalRate/2;
% initialize
hours = 0;
normal_total = 10;
mutant_total = 10;
% loop to let cells grow
while hours <= runHours % run until the final number of hours is reached
hours = hours + 1; % count up the hours
% compute new populations
normal_total = normal_total*normalRate;
mutant_total = mutant_total*mutantRate;
end
その他の回答 (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!