
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, Fourth Edition: A Practical Introduction to Programming and Problem Solving
- The customer help center in your company receives calls from customers who need help with some of the customized software solutions your company provides. Your company claims that the average waiting time is 7 minutes at the busiest time, from 8 a.m. to 10 a.m., Monday through Thursday. One of your main clients has recently complained that every time she calls during the busy hours, the waiting time exceeds 7 minutes. You conduct a statistical study to determine the average waiting time with a sample of 35 calls for which you obtain an average waiting time of 8.15 minutes. If the population standard deviation is known to be 4.2 minutes, and a = 0.05, the p-value is approximately 0.05 0.025 ○ 0.053 ○ 0.10 ○ 0.026arrow_forwardThe procedures for doing hypothesis testing of proportions and hypothesis testing of means are similar, but what is one of the differences they have ?arrow_forwardThe p-value is the probability of a statistic being at most as extreme as the observed value when Ho is false. the probability that the alternative hypothesis is true. O the probability that the null hypothesis is true. O the probability of a statistic being at most as extreme as the observed value when Ho is true. O the probability of a statistic being at least as extreme as the observed value when Ho is true.arrow_forward
- Why the correct answer in 9b is 1/150? What is the solution to the answer?arrow_forwardHow to get the answer in question 8 letter c? What is the solution to get the answer of 12.6?arrow_forwardThe daily sales (in hundreds of dollars) for a store in one month (30 days) are: 15, 22, 18, 25, 19 12, 17, 24, 20, 23 30, 28, 26, 31, 35 21, 19, 27, 18, 20 16, 15, 32, 30, 17 24, 29, 22, 33, 25 a. Construct a grouped frequency distribution with class intervals of width 5 starting from 12. b. Draw a histogram and state whether the data is symmetric, skewed left, or skewed right. Instruction: 1. Please answer the question given above for your tutorial participation mark. 2. Please upload your hand-written answers (pdf format).arrow_forward
- Algebra & Trigonometry with Analytic GeometryAlgebraISBN:9781133382119Author:SwokowskiPublisher:CengageAlgebra: Structure And Method, Book 1AlgebraISBN:9780395977224Author:Richard G. Brown, Mary P. Dolciani, Robert H. Sorgenfrey, William L. ColePublisher:McDougal Littell

