While loop word problem

조회 수: 16 (최근 30일)
Emily Stadnicki
Emily Stadnicki 2020년 9월 30일
댓글: Emily Stadnicki 2020년 9월 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
Sindar
Sindar 2020년 9월 30일
show us what you've got so far
Emily Stadnicki
Emily Stadnicki 2020년 9월 30일
This is what I have so far!
>> normal = 10;
>> mutant = 10;
>> h = [1 2 3 4 5 6 7 8 9 10 11 12];
>> normal_total = h*(3*normal);
>> mutant_total = h*(1.5*mutant);
>> while mutant_total <= normal_total
if h = 12

댓글을 달려면 로그인하십시오.

채택된 답변

Jon
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
  댓글 수: 1
Emily Stadnicki
Emily Stadnicki 2020년 9월 30일
Thank you so much! I was definitely missing some fundamental steps!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

제품

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by