0% found this document useful (0 votes)
11 views

Matlab Pract Problem

This document provides two Matlab programming exercises. The first asks the user to input a critical number between 0 and 1, then tracks how many random numbers generated by rand must be greater than the critical number before outputting the number of attempts and unsuccessful numbers. The second is similar but adds a tolerance window - it tracks how many tries until a random number falls within that window of the critical number.

Uploaded by

Shaukat Ali Shah
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views

Matlab Pract Problem

This document provides two Matlab programming exercises. The first asks the user to input a critical number between 0 and 1, then tracks how many random numbers generated by rand must be greater than the critical number before outputting the number of attempts and unsuccessful numbers. The second is similar but adds a tolerance window - it tracks how many tries until a random number falls within that window of the critical number.

Uploaded by

Shaukat Ali Shah
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Matlab programming exercises ME345 Modeling and Simulation Problem 1.

. Write a Matlab code that will allow a user to enter in a critical number between 0 and 1, and then track the number of times that a random number must be generated in order to be greater than the critical number . Output the number of attempts that were necessary, and the numbers that were not successful. Be sure that you code is working correctly. (Hint: the command rand will be useful here)

Problem 2. This problem is similar to Problem #1 but with some extra complications. Write a Matlab code that will allow a user to enter in a critical number between 0 and 1, and then a tolerance that will provide a window. Then track how many tries it takes until the random number falls within the window. For example, if the user selects 0.5 as the critical number and 0.01 as the tolerance, how many times does it take for a random number to be generated that is between 0.49 and 0.51. Again, store the numbers that did not work.

You might also like