please do it in matlab matlab languages please task four is realted to task 5 pl
ID: 3868423 • Letter: P
Question
please do it in matlab
matlab languages please
task four is realted to task 5
please do both tasks
TASK 4 I will survive? to nt Some activities carry with them a relatively high risk of death. For example around 4% of climbers who attempt to summit Everest die. The physicist Richard Feynman estimated that the chances of failure of a space shuttle mission with loss of vehicle and life were roughly 1%. Tragically two al: shuttles were lost. This raises the question of how many shuttle missions could NASA have expected to launch before losing a shuttle. Flights can be determined to be successful or not. To do this we will compare a randomly generated value (between 0 and 100) and see if it is in the range 0 to 1 (a value in this range will be deemed to be a failed mission corresponding to the 1% chance of losing a shuttle). Use a while loop to predict how many flights NASA could have made before losing a shuttle. When your while loop has finished your script file should write a message telling NASA how many successful missions they made Sample output: task3 You completed 12 successful missions before losing a shuttle Hint: You can generate a random number between 0 and 100 using the rand function which generates a value between 0 and 1 and then multiplying it by 100: 100 rand T LOVE GETTING I SET UP A SCRIPT I GAVE IT $365, So PACKAGES. WHAT IF YOU JUST END UP WITH LOTS OF CRAP? TO SEARCH EBAY ET. AL. FOR SI mEns ME SOMETHING RANDOM LL GME IT AWAY WITH FREE SHIPPING EPCH DAY IT CAN CUY BUT In SURE Iu GET SOME INTERESTING STUFF DAY LENGTH OF ARSE HOSEDAY 2: SKI MASK DAY 3: BEAR TRAP DAY 4 TOURIST AP D DAY 5:LU In STOPPIN GEFORE IE OF THE PENTAGON COULD BE HANDY ITS SPRING,Explanation / Answer
Task 4 -
Variables -
Logic -
Code -
count = 0;
temp = 1;
while temp == 1
n = 100*rand;
if n > 1
count = count + 1;
elseif n >= 0 && n <= 1
disp(sprintf("You completed %d successful missions before loosing a shuttle",count))
temp = 0;
end
end
Task 5 -
This task is similar to the one solved above with some additional twists like - it has given us to test a certain number of simulations instead of 1 simulation that we were testing above.
Variables -
Logic -
Code -
prompt = "How many simulations would you like to run"
itr = input(prompt);
successful_missions = [];
for i = 1:itr
count = 0;
temp = 1;
while temp == 1
n = 100*rand;
if n > 1
count = count + 1;
elseif n >= 0 && n <= 1
successful_missions(i) = count;
temp = 0;
end
end
end
disp(successful_missions)
hist(successful_missions)
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.