Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a GUI implemented in MATLAB using App Designer that calls the three functions in Tasks 1 3 . tasks are based on Buffon s

Write a GUI implemented in MATLAB using App Designer that calls the three functions in Tasks
1
3.
tasks are based on
Buffon
s needle
experiment.
for example this is task one :
"function
[
p
,
crossings
]
=
BuffonStandardPi
(
width
,
length, throws
)
crossings
=
0
;
for n
=
1
:throws
%
Randomly place the needle's midpoint and angle
midpoint
=
width
*
rand
(
)
;
angle
=
pi
*
rand
(
)
;
%
Calculate the distance from the midpoint to the nearest line
distance
_
to
_
line
=
min
(
midpoint
,
width
-
midpoint
)
;
%
Check if the needle crosses a line
if distance
_
to
_
line
<
(
length
/
2
)
*
sin
(
angle
)
crossings
=
crossings
+
1
;
end
end
%
Estimate pi using the crossings
if crossings
>
0
p
=
(
2
*
length
*
throws
)
/
(
width
*
crossings
)
;
else
p
=
Inf;
%
If no crossings, the estimate of pi goes to infinity
end
end"
The GUI must
1.
Allow the user to select which task is run.
2.
Allow the user to adjust the number of needles, dropped squares, and parallel planks of wood, from default values. The program should allow
at least
1
,
000
,
000
needles
/
dropped squares and
10
parallel planks of wood. Note: not all needles need to be displayed if more than
1000
are
dropped.
3.
Before running the simulation allow the user to adjust the sizes of the needles, dropped squares, and parallel planks of wood from default
values.
4.
Display the parallel planks of wood.
5.
Display the dropped needles
/
squares
.
6.
Highlight in a different colour all needles
/
dropped squares that intersect the cracks between planks.
7.
Display the value estimated by the Monte Carlo simulation.
8.
Allow the user to customize elements of the displayed value
(
e
.
g
.
font size, colour
)
.
9.
an additional function to be applied to Task
1
needle dropping only:
It should allow the user to select a needle by clicking on or near it with the mouse. The needle will then be highlighted in a different colour and The n needles with most similar orientation will then be highlighted in yet another colour. The default value is n
=
3
,
and the value of n can
be modified through the GUI.
10.
Allow a mixture of different sized needles to be used.
11. Support saving and loading back sets of needles such that previous results can be combined to produce better estimates.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Systems Design Implementation And Management

Authors: Peter Robb,Carlos Coronel

5th Edition

061906269X, 9780619062699

More Books

Students also viewed these Databases questions