Question
simple in matlab

Page < 1 > of 2 - ZOOM + 4 ordem prayerup Question 2 (10 Points) A stick of length one is randomly broken in two-pieces. In a
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Program:

format long;
sum = 0;
for i=1:1000000
% rand function generates a real number between 0 and 1 over a uniform
% distribution
n = rand();
if n>(1-n)
ratio = (1-n)/n;
else
ratio = n/(1-n);
end
sum = sum + ratio;
end
avg_ratio = sum/1000000.0;
sprintf('Avg ratio: %.10f', avg_ratio)
sprintf('2ln2 -1: %.10f', 2*log(2)-1)
%Answers upto 10 decimals
%Avg ratio: 0.3863882882
%Note: average ratio changes over time
%2ln2 -1: 0.3862943611

Untitled. m x + format long; sum = 0; for i=1:1000000 rand function generates a real number between 0 and 1 over a uniform di

Add a comment
Know the answer?
Add Answer to:
simple in matlab Page < 1 > of 2 - ZOOM + 4 ordem prayerup Question...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • need help with matLab Question 1 (20 Points) Write a well-documented MATLAB script hmwk7Q1.m that simulates...

    need help with matLab Question 1 (20 Points) Write a well-documented MATLAB script hmwk7Q1.m that simulates tossing 100 coins into a unit square. As shown in the scatter plot. Location of Simulated Coins In Unit Square 1 o0 Ooo 05 04 03 02 oo 0.1 2 03 4 05 07 1 xpostion Hmwk7Q1.fig Consider organizing your MATLAB script into the following sections. % housekeeping (performs clearing of figures, workspace, and command lines) % Initialize the Number of Coins To Simulate...

  • Page < 2 > of 8 ZOOM + 1) Draw the mechanism for the formation of...

    Page < 2 > of 8 ZOOM + 1) Draw the mechanism for the formation of 2-bromopropane. Use the mechanism to explain why 1-bromopropane is not formed in this reaction (10 points) Br HBr Not Br us JUL OL 31

  • .2.pui Page < 1 > of 3 0 - ZOOM Write the system of inequalities that...

    .2.pui Page < 1 > of 3 0 - ZOOM Write the system of inequalities that describes the possible solutions to the problem. 4) The Acme Class Ring Company designs and sells two types of rings: the VIP and the SST. The company can produce up to 56 rings each day, using up to 140 total man-hours of labor. It takes 2 man-hours to make one VIP ring and 7 man-hours to make one SST ring. Let x represent the...

  • Answer part (a) on a blank page. Matlab simulations must be written in script files with...

    Answer part (a) on a blank page. Matlab simulations must be written in script files with your names embedded. Attach your Matlab simulations (both .m and fig files) at the back. (a) For the simplified rocket model shown in Figure 2 Find the expression for the signal x (t) in terms of singularity ramp r(t) and unit step u (t) functions. Explain briefly how the expression is obtained, with graphical aids if possible. (4 points) From the expression you obtained...

  • Answer part (a) on a blank page. Matlab simulations must be written in script files with...

    Answer part (a) on a blank page. Matlab simulations must be written in script files with your names embedded. Attach your Matlab simulations (both .m and fig files) at the back. (a) For the simplified rocket model shown in Figure 2 Find the expression for the signal x (t) in terms of singularity ramp r(t) and unit step u (t) functions. Explain briefly how the expression is obtained, with graphical aids if possible. (4 points) From the expression you obtained...

  • JUL Download A Alternative formats of 2 ZOOM + 1. Page Bicycle A is 100 miles...

    JUL Download A Alternative formats of 2 ZOOM + 1. Page Bicycle A is 100 miles west of runner B. Bicycle A travels east at 13 mph and runner B travels north at 5 mph. How fast is the distance between the bicycle and the runner changing 4 hours later? (5 points) x A B 100

  • matlab The Homework should be submitted as a script (.m) file Write a script areaMenu that...

    matlab The Homework should be submitted as a script (.m) file Write a script areaMenu that will print a menu consisting of "Cylinder," "Circle," and "Rectangle." It waits for the user to choose from the menu then call the corresponding function of each choice as follows: 1- Cylinder will call the function (cyl) which prompts the user for the radius and height of the cylinder, then calculates and prints area of the cylinder. 2- Circle will call the function (cir)...

  • i BOX Number- " Parts reference Text CommentsHeader&Footer Links MATLAB Lab 8 This exercise was done previously for a full circle. Perform all the steps shown including the plot, but only...

    i BOX Number- " Parts reference Text CommentsHeader&Footer Links MATLAB Lab 8 This exercise was done previously for a full circle. Perform all the steps shown including the plot, but only for the function shown in part b). Objective: In calculus, integration allows us to find the area under a curve. Numerical methods exist which enable us to approximate the area An interesting approach is to randomly select points in an x-y plane and find the fraction of those points...

  • matlab 1. (5 pts) This question requires: matrix manipulation, single for loop, ifelse statement, data input,...

    matlab 1. (5 pts) This question requires: matrix manipulation, single for loop, ifelse statement, data input, m script file We have 80 number grades held in a matrix (grad m as you did the gradebook project in es MATLAB lab 1). The letter grades are given by following the rule: "A" 90)."B" 80), "C" P 70), "D" P 60), "F" (<60) and "S" "0): "S" standards for sick. Write one script file to Give the letter grade to EACH number...

  • 1) a) Write MATLAB function that accepts a positive integer parameter n and returns a vector...

    1) a) Write MATLAB function that accepts a positive integer parameter n and returns a vector containing the values of the integral (A) for n= 1,2,3,..., n. The function must use the relation (B) and the value of y(1). Your function must preallocate the array that it returns. Use for loop when writing your code. b) Write MATLAB script that uses your function to calculate the values of the integral (A) using the recurrence relation (B), y(n) for n=1,2,... 19...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT