A programmer writes a MATLAB program shown below. Write below which control structures are used in...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
A programmer writes a MATLAB program shown below. Write below which control structures are used in this program. Explain your answer. sum_x = 0; sum_x2 = 0; n =input('Enter number of points: '); if n < 2 % Insufficient data disp ('At least 2 values must be entered.'); else for ii = 1:n x = input('Enter value: '); sum_x = sum_x + x; sum_x2 = sum_x2 + x^2; end x_bar = sum_x/n; std_dev = sqrt((n * sum_x2 - sum_x^2) / (n * (n-1))); fprintf('The mean of this data set is: %f\n', x_bar); fprintf('The standard deviation is: %f\n', std_dev); fprintf('The number of data points is: %f\n', n); end A programmer writes a MATLAB program shown below. Write below which control structures are used in this program. Explain your answer. sum_x = 0; sum_x2 = 0; n =input('Enter number of points: '); if n < 2 % Insufficient data disp ('At least 2 values must be entered.'); else for ii = 1:n x = input('Enter value: '); sum_x = sum_x + x; sum_x2 = sum_x2 + x^2; end x_bar = sum_x/n; std_dev = sqrt((n * sum_x2 - sum_x^2) / (n * (n-1))); fprintf('The mean of this data set is: %f\n', x_bar); fprintf('The standard deviation is: %f\n', std_dev); fprintf('The number of data points is: %f\n', n); end
Expert Answer:
Answer rating: 100% (QA)
The control structures used in this program are if statement The i... View the full answer
Related Book For
Posted Date:
Students also viewed these programming questions
-
Which of the following control structures are used in flowchart A in Figure 6-28? a. Sequence b. Selection c. Repetition T.
-
Which of the following control structures are used in flowchart B in Figure 6-28? a. Sequence b. Selection c. Repetition T.
-
Which of the following control structures are used in flowchart C in Figure 6-28? a. Sequence b. Selection c. Repetition T.
-
If the demand function and supply function for Z-brand phones are p + 2q = 100 and 35p + 20q = 350, respectively, compare the quantity demanded and the quantity supplied when p = 14. Are there...
-
A sample question from the draft of the Pohattan Power Company questionnaire reads: I have been with the company: 20upwards years 1015 years upwards 510 years upwards less than a year Check one that...
-
The radius of a spherical ball is increasing at a rate of 2 cm/min. At what rate is the surface area of the ball increasing when the radius is 8 cm?
-
The following MINITAB output presents a multiple regression equation y = b0 + b1x1 + b2x2 + b3x3 + b4x4 + b5x5. It is desired to drop one of the explanatory variables. Which of the following is the...
-
You are considering two independent projects, Project A and Project B. The initial cash outlay associated with Project A is $50,000 and the initial cash outlay associated with Project B is $70,000....
-
The Bodyshop has issued a bank-accepted bill to fund a short-term business project. The bill was issued for 180 days, with a face value of $1 800 000 and a yield of 9.87 per cent per annum. PART A:...
-
Open the Orders Solution.sln file contained in the VB2017\Chap03\Orders Solution folder. The interface provides a button for adding the number ordered to the total ordered, and a button for...
-
Greg purchased an annuity for $500,000 in 2021, which will pay him $35,000 per year for life. His life expectancy is 20 years. If he receives $35,000 in the current year (2022), Calculate the amount .
-
1 . The company receives cash from a customer for work to be performed next year. Question options: Assets Go Up Assets Go Down Liabilities Go Up Liabilities Go Down Equity Goes Up ( Due to revenue )...
-
Katie Fowles is beginning her study of the statement of cash flows. She understands the basic idea: a statement of cash flows reports the amount of cash collected and the amount of cash paid during...
-
By reviewing the Federal Reserve Web site and/or other relevant resources, refer to the latest 2 changes to the discount rate and federal funds rate target made by the U.S. Federal Reserve and...
-
For this Reader Response, I want you to look at how Ken Liu told this story. Upon finishing the reading, look at the story on the surface level first and then go deeper. - How does the author use...
-
The ff. is the sales budget of MM for the period Jan. to June: Months Sales Months Sales Jan 100,000 April 80,000 Feb 90,000 May 70,000 March 90,000 June 70,000 The company's projection is to have...
-
help! i know the first part, just not the second! Consider the following curve. \[ y=\sqrt{2-62 x} \] Find the slope \( m \) of the tangent line at the point \( (-1,8) \). \( m= \) Find an equation...
-
Air pollution generated by a steel mill is an example of a) a positive production externality. b) a negative production externality. c) a public good. d) the free-rider problem. State and local taxes...
-
A variable of a population has mean and standard deviation . For a large sample size n, answer the following questions. a. Identify the distribution of x-bar. b. Does your answer to part (a) depend...
-
Following is a gender frequency distribution for students in Professor Weiss's introductory statistics class. Gender Frequency Male .......... 17 Female ......... 23 Two students are selected at...
-
State the four assumptions required for one-way ANOVA. How crucial are these assumptions?
-
Calculate the residual enthalpy and entropy for propane at \(312 \mathrm{~K}\) and \(2 \mathrm{MPa}\) using the van der Waals equation of state, given that \(a=0.877 \mathrm{~Pa}\left(\mathrm{~m}^{3}...
-
Using the generalized virial coefficient of correlation, estimate the residual enthalpy and entropy for ethylene at \(339.7 \mathrm{~K}\) and \(1 \mathrm{bar}\), given that \(T_{\mathrm{C}}=283...
-
Derive an expression to calculate the change in enthalpy and entropy of a real gas obeying the following equation of state along an isothermal path between the initial and final pressures \(P_{1}\)...
Study smarter with the SolutionInn App