
Concept explainers
To find:
The output of the following sequence of statements and expressions, and verify them.
mat = [1:3; 44 9 2; 5:-1:3]
mat(3, 2)
mat(2,:)
size(mat)
mat(:, 4) = [8;11;33]
numel(mat)
v = mat(3,:)
v(v(2))
v(1) = []
reshape(mat, 2, 6)
Answer to Problem 2.2P
Solution:
The output of the following sequence of statements and expressions:
“mat = [1:3; 44 9 2; 5:-1:3]”, “mat(3, 2)” “mat(2,:)”, “size(mat)”, “mat(:, 4) = [8;11;33]”, “numel(mat)”, “v = mat(3,:)”, “v(v(2))”, “v(1) = []”, and “reshape(mat, 2, 6)” are “
Explanation of Solution
Consider the following statement,
mat = [1:3; 44 9 2; 5:-1:3]
The statement will generates the matrix with the elements of the row with 1, 2, 3; second row 44, 9, 2; and the third row with 5, 4, 3.
So, the output is “
Consider the following statement,
mat(3, 2)
This command generates the value that is placed at third row and second column of the matrix “mat”.
So, the output is “ans = 4”.
Consider the following statement,
mat(2,:)
This command generates the second row elements of the matrix “mat”.
So, the output is “ans = 44 9 2”.
Consider the following statement,
size(mat)
This command generates the order of matrix.
So, the output is “ans = 3 3”.
Consider the following statement,
mat(:, 4) = [8;11;33]
This command includes the fourth column to the matrix “mat”.
So, the output is “
Consider the following statement,
numel(mat)
This command generates the number of elements present in the matrix “mat”.
So, the output is “ans = 12”.
Consider the following statement,
v = mat(3,:)
This command generates the third row elements from the matrix “mat”.
So, the output is “5 4 3 33”.
Consider the following statement,
v(v(2))
Since,
So, the output is “ans = 33”.
Consider the following statement,
v(1) = []
This command generates the elements of “v” eliminating the first elements.
So, the output is “v = 4 3 33”.
And consider the following statement,
reshape(mat, 2, 6)
This command changes the order of the matrix from
So, the output is “
MATLAB Code:
clc
clear all
close all
mat = [1:3; 44 9 2; 5:-1:3]
% Define the instruction in which the statement will generates the matrix with the elements of the row with 1, 2, 3; second row 44, 9, 2; and the third row with 5, 4, 3.
mat(3, 2)
% Define the instruction in which the command generates the value that is placed at third row and second column of the matrix “mat”.
mat(2,:)
% Define the instruction in which the command generates the second row elements of the matrix “mat”.
size(mat)
% Define the instruction in which the command generates the order of matrix.
mat(:, 4) = [8;11;33]
% Define the instruction in which the command includes the fourth column to the matrix “mat”.
numel(mat)
% Define the instruction in which the command generates the number of elements present in the matrix “mat”.
v = mat(3,:)
% Define the instruction in which the command generates the third row elements from the matrix “mat”.
v(v(2))
% Define the instruction in which the command generates the value of the v(v(2)).
v(1) = []
% Define the instruction in which the command generates the elements of “v” eliminating the first elements.
reshape(mat, 2, 6)
% Define the instruction in which the command changes the order of the matrix from 3 into 3 to 2 into 6.
Save the MATLAB script with name, chapter2_54793_2_2P.m in the current folder. Execute the script by typing the script name at the command window to find the answer of the given following sequence of statements and expressions.
Result:



Therefore, the output of the following sequence of statements and expressions:
“mat = [1:3; 44 9 2; 5:-1:3]”, “mat(3, 2)” “mat(2,:)”, “size(mat)”, “mat(:, 4) = [8;11;33]”, “numel(mat)”, “v = mat(3,:)”, “v(v(2))”, “v(1) = []”, and “reshape(mat, 2, 6)” are “
Want to see more full solutions like this?
Chapter 2 Solutions
MATLAB: A Practical Introduction to Programming and Problem Solving
- please give correct answer of this statistics and probability question.arrow_forwardCould you please help me answer parts b and c. Thanksarrow_forwardSuppose that we have data y = (1,...,n). Each data point y; is assumed to be generated by a distribution with the following probability density function: P(yi | n)=3nye, y; ≥0. The unknown parameter is >0. (a) Write down the likelihood for n given y, and find an expression for the maximum likelihood estimate (MLE) of n. (b) A Gamma(a, 3) distribution is chosen as the prior distribution for 7, where a > 0 and > 0 are known. Show that the posterior distribution of n, denoted p(n | A), is also a gamma distribution with updated parameters that you should determine.arrow_forward
- Do the data provide compelling evidence (at α=0.05) for concluding that true average strength for the 1078 grade exceeds that for the 1064 grade? Show all your work. Estimate the difference between true average strengths for the two grades with a 95% confidence interval for the previous problem.arrow_forwardUse Minitab and the GPA data (GPAData.xlsx) to answer the following. a) (15 points) Is there a mean difference in High School GPA and a person's GPA following their first year of college? State the relevant hypotheses and provide the p-value from the output. Include a decision and interpretation at a 10% level of significance. b) (5 points) Is the assumption of normality satisfied? Include any plots you make to check the normality assumption and comments on your observations.arrow_forwardA researcher wants to perform a hypothesis test to see if the mean salary of the faculty in private and public institutions are different. Random samples of 36 faculty from private and public institutions were selected. Salaries of the selected faculty from private and public institutions are provided to you in facultysalary.csv file. 1. Make side-by-side boxplots of the salaries for faculty in private and public institutions (In MINITAB, go to Graphs-- >Boxplot-->and explore the available options to see how to make a side-by-side boxplot of the data). 2. Comment on your observations from the side-by-side boxplot made in part 1. 3. Calculate the descriptive statistics: mean, standard deviation for the two samples and attach the MINITAB output. 4. When carrying out a hypothesis test to achieve the aforementioned goal, would you recommend using pooled variance approach or unpooled variance approach? Provide reasoning for your choice. 5. Regardless what you recommend in part 4, carry out…arrow_forward
- Dave Hughes owns a local restaurant. He wonders if a redesign of the menu will increase, on average, the amount customers spend when visiting his establishment. For the following scenario, pick a statistical method we discussed regarding comparing two groups that would be appropriate for analyzing the problem. a) Hughes records the mean sales the week before the change and the week after the change and then wonders whether the difference is statistically significant. [ Select ] b) Hughes randomly samples 100 people and shows both menus to each person, asking them to rate each menu from 0 (very poor) to 20 (excellent) and then wonders whether the difference is statistically significant. [ Select ] c) Hughes randomly samples 100 people and randomly separates them into two groups of 50. He asks those in group 1 to give a rating of ‘positive’ or ‘negative’ to the old menu and those in group 2 to give a rating of ‘positive’ or ‘negative’ to the new menu. He then computes the proportion of…arrow_forwardPlease don't answer of this statistics and probability question without knowledge.arrow_forwardPlease don't use ChatGPT! i will unhelpful. statistics and probaarrow_forward
- Don't answer without proper knowledge of this statistics and probability question:arrow_forwardSearch A random sample of n₁ =217 people who live in a city were selected and 107 identified as a "student". A random sample of n₂ =109 people who live in a rural area were selected and 66 identified as a "student". Find the 98% confidence interval for the difference in the proportion of people that live in a city who identify as a "student" and the proportion of people that live in a rural area who identify as a "student." a. The point estimate for difference in population proportions (City group minus Rural Area group) = Round answers to 3 decimal places. -0.112 b. Fill in the blanks of the following statement. Round answers to 3 decimal places. We are 98 0% confident that the difference in population proportion of people who identified as a "student" in city and rural area falls between -0.247 0.022 0.022 and c. Select the correct conclusion based on the above confidence interval. O Since the above confidence interval gives only negative values, we have 98% confident that the…arrow_forwardCould you please provide solutions to the follwoing questions.Thanksarrow_forward
- Algebra & Trigonometry with Analytic GeometryAlgebraISBN:9781133382119Author:SwokowskiPublisher:Cengage
Algebra: Structure And Method, Book 1AlgebraISBN:9780395977224Author:Richard G. Brown, Mary P. Dolciani, Robert H. Sorgenfrey, William L. ColePublisher:McDougal Littell

