Homework%202%20Solutions - Homework 2 Solutions Table of Contents Problem Problem Problem Problem Problem Problem Problem Problem Problem 1 2 3 4 5 6 7

Homework%202%20Solutions - Homework 2 Solutions Table of...

This preview shows page 1 - 2 out of 5 pages.

1 Homework 2 Solutions Table of Contents Problem 1 - YourAge.m ...................................................................................................... 1 Problem 2 - CoinToss.m ...................................................................................................... 1 Problem 3 - ThankYou.m .................................................................................................... 2 Problem 4 - PiSeries.m ........................................................................................................ 2 Problem 5 - PiSeriesMultiple.m ............................................................................................ 2 Problem 6 - MyMeanVector.m ............................................................................................. 3 Problem 7 - plotGaussian.m ................................................................................................. 3 Problem 8 - Fibonacci.m ..................................................................................................... 4 Problem 9 - RunningAvg.m ................................................................................................. 4 The following file provides the solutions for all of the homework problems. Problem 1 - YourAge.m Prompts the user for their age and outputs a response based on that data. clear clc % age = input('Please enter your age: '); age = 22; % Example because the input command doesn't publish well if age < 40 disp([ 'You are ' , num2str(age), '! That''s young!' ]); elseif age < 100 disp([ 'You are ' , num2str(age), '! You''re young at heart!' ]); else disp([ 'You are ' , num2str(age), '! Wow, that is old!' ]); end You are 22! That's young! Problem 2 - CoinToss.m Prompts the user to choose heads or tails (h and t) for a coin toss, then performs a simulated toss and reports the result. If the player does not choose h or t, the player should automatically lose.
Image of page 1
Image of page 2

You've reached the end of your free preview.

Want to read all 5 pages?

  • Fall '14
  • Mean, .........

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

Stuck? We have tutors online 24/7 who can help you get unstuck.
A+ icon
Ask Expert Tutors You can ask You can ask You can ask (will expire )
Answers in as fast as 15 minutes