Chapter 5: Problem 1
What is the difference between a script file and a function?
Chapter 5: Problem 1
What is the difference between a script file and a function?
All the tools & learning materials you need for study success - in one app.
Get started for freeLinear Least-Squares Fit. Develop a function that will calculate slope \(m\) and intercept \(b\) of the least-squares line that best fits an input data set. The input data points \((x, y)\) will be passed to the function in two input arrays, \(x\) and \(y\). (The equations describing the slope and intercept of the least- squares line are given in Example \(4.7\) in the previous chapter.) Test your function using a test program and the 20-point input data set given in Table 5.2.
Probability of Detection \(\left(P_{2}\right)\) versus Probability of False Alarm \(\left(P_{\text {a }}\right)\). The signal strength returned by a radar target usually fluctuates over time. The target will be detected if its signal strength exceeds the detection threshold for any given look. The probability that the target will be detected can be calculated as $$ P_{i=}=\frac{\text { Number of Target Detections }}{\text { Total Number of Looks }} $$ Suppose that a specific radar looks repeatedly in a given direction. On cach look, the range between \(10 \mathrm{~km}\) and \(20 \mathrm{~km}\) is divided into 100 independent range samples (called range gates). One of these range gates contains a target whose amplitude has a normal distribution with a mean amplitude of 7 volts and a standard deviation of I volt. All 100 of the range gates contain system noise with a mean amplitude of 2 volts and a Rayleigh distribution. Determine both the probability of target detection \(P_{d}\) and the probability of a false alarm \(P_{1,}\) on any given look for detection thresholds of \(8.0,8.5,9.0,9.5,10.0,10.5,11.0,11.5\), and \(12.0 \mathrm{~dB}\). What threshold would you use for detection in this radar? (Hint: Perform the experiment many times for each threshold and average the results to determine valid probabilities.)
Write three MATLAB functions to caiculate the hyperbolic sine, cosine, and tangent functions. $$ \sinh (x)=\frac{e^{x}-e^{-x}}{2}, \cosh (x)=\frac{e^{x}+e^{-x}}{2}, \tanh (x)=\frac{e^{x}-e^{-x}}{e^{x}+e^{-x}} $$ Use your functions to plot the shapes of the hyperbolic sine, cosine, and tangent functions.
When a function is called, how is data passed from the caller to the function, and how are the results of the function returned to the caller?
Read Traffic Density. Function random0 produces a number with a uniform probability distribution in the range \([0.0,1.0)\). This function is suitable for simulating random events if each outcome has an equal probability of occurring. However, in many events the probability of occurrence is not equal for every event, and a uniform probability distribution is not suitable for simulating such events. For example, when traffic engineers studied the number of cars passing a given location in a time interval of length \(t\), they discovered that the probability of \(k\) cars passing during the interval is given by the equation $$ P(k, t)=e^{-\lambda t} \frac{(\lambda t)^{4}}{k !} \text { for } t \geq 0, \lambda>0, \text { and } k=0,1,2, \ldots $$ This probability distribution is known as the Poisson distribution: it occurs in many applications in science and engineering. For example, the number of calls \(k\) to a telephone switchboard in time interval \(t\), the number of bacteria \(k\) in a specified volume \(t\) of liquid, and the number of failures \(k\) of a complicated system in time interval \(t\) all have Poisson distributions. Write a function to evaluate the Poisson distribution for any \(k, t\), and A. Test your function by calculating the probability of \(0,1,2, \ldots, 5\) cars passing a particular point on a highway in I minute, given that \(\lambda\) is \(1.6\) per minute for that highway. Plot the Poisson distribution for \(t=1\) and \(\lambda=1.6\).
What do you think about this solution?
We value your feedback to improve our textbook solutions.