Question

In: Computer Science

Given the matrix as shown below n_array = 3 1 8 3 5 7 4 9...

Given the matrix as shown below

n_array =

3 1 8

3 5 7

4 9 2

Write a M-file script program that generates this n_array, and answer each question using one line of MATLAB statement.

a) Replace the second column of the n_array with a column of 0s

b) Replace the element in the second-row, third-column with a zero

c) Change the n_array to a 4 x 3 array by adding a row of 0s

The end result for the n_array will be

n_array =

3 0 8

3 0 0

4 0 2

0 0 0

Solutions

Expert Solution

NOTE : PROGRAM IS DONE WITH MATLAB PROGRAMMING LANGUAGE.

HERE AS PER INSTRUCTION OF QUESTION EACH QUESTION (a),b),c)) ARE SOLVED WITH ONE LINE OF MATLAB CODE.

PROGRAM

%generates this n_array
n_array = [3 1 8; 3 5 7; 4 9 2];
fprintf('\nGien Matrix is\n\n')
disp(n_array);

%perform a) b) c) using one line of MATLAB statement.
%a) Replace the second column of the n_array with a column of 0s
n_array(:,2)=0; % after colon(:) 2 signifies 2 nd column

%b) Replace the element in the second-row, third-column with a zero
n_array(2,3)=0; % row number 2 and column number 3

%c) Change the n_array to a 4 x 3 array by adding a row of 0s
n_array(4,:)=0; %4 before colon(:) signifies full 4th row

%The end result for the n_array will be
fprintf('\nEnd result of n_array is\n\n');
disp(n_array);

SCREN SHOT

OUTPUT


Related Solutions

x 2 8 5 9 4 3 9 6 7 8 y 3 6 5 7...
x 2 8 5 9 4 3 9 6 7 8 y 3 6 5 7 9 7 4 6 9 9 -5.48x + 0.17 5.48x + 0.17 -0.17x + 5.48 0.17x + 5.48
For the data set shown​ below. x   y 3   4 4   5 5   8 7   12...
For the data set shown​ below. x   y 3   4 4   5 5   8 7   12 8   15 Find the estimates of β0 and β1. β0≈b0=-3.256 ​ (Round to three decimal places as​ needed.) β1≈b1=2.233 (Round to three decimal places as​ needed.) (b) Compute the standard​ error, the point estimate for σ. Se=0.5972 ​(Round to four decimal places as​ needed.) ​(c) Assuming the residuals are normally​ distributed, determine sb1. sb1=0.144 ​(Round to three decimal places as​ needed.) ​(d) Assuming the...
Given the matrix 7 7 -4 12 -5 A = 9 10 2 6 13 8 11 15 4 1 3. a. Sort each column and store the result in an array B.
Given the matrix a. Sort each column and store the result in an array B.b. Sort each row and store the result in an array C.c. Add each column and store the result in an array D.d. Add each row and store the result in an array E.  
3, 7, 8, 5, 6, 4, 9, 10, 7, 8, 6, 5 Using the previous question...
3, 7, 8, 5, 6, 4, 9, 10, 7, 8, 6, 5 Using the previous question 's scores, If three points were added to every score in this distribution, what would be the new mean? If three points were added to every score in this distribution, what would be the new standard deviation. Remember, you have already calculated population standard deviation in a previous problem. This problem requires two answers.
Given: x y -5 1 -4 5 -3 4 -2 7 -1 10 0 8 1...
Given: x y -5 1 -4 5 -3 4 -2 7 -1 10 0 8 1 9 2 13 3 14 4 13 5 18 What are the confidence limits (alpha = 0.05) for the true mean value of Y when X = 3?
A = [4, 5, 9] B = [-4, 5, -7] C = [2, -7, -8, 5]...
A = [4, 5, 9] B = [-4, 5, -7] C = [2, -7, -8, 5] D = [1, -9, 5, -3] E = [3, 3, -1] Uz = 1/|z| ^z d(X,Y) = (Rθ) d = diameter R = Radius θ = Theta Find a. Uc b. d (D, C) c. Let P = B + 3E, UP = d. A x B e. 3B x E f. C x D
For the following data set, X: 9, 6, 8, 3, 8, 9, 3, 4, 3, 7:...
For the following data set, X: 9, 6, 8, 3, 8, 9, 3, 4, 3, 7: Calculate: 1. Variance 2. Mode 3. Mean 4. Mean Average Deviation (MAD) about the mean 5. Median
For the matrix X answer the questions below. X = ( 4 8 8 ; 3...
For the matrix X answer the questions below. X = ( 4 8 8 ; 3 6 − 9 ), this is a 2x3 matrix (a) Calculate XX’ and compute the corresponding Eigen values and Eigen vectors. (b) Obtain the singular-value decomposition of the matrix X. Note that: Eigen values for X’X are: λ1 =150, λ2 = 120, and λ3 = 0. The corresponding Eigen vectors are: eigenvector1 = 1/√30 (1 2 5), eigenvector2 = 1/√6 (1 2 -1), and...
Consider the following set of observations: Obs. 1 2 3 4 5 6 7 8 9...
Consider the following set of observations: Obs. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 input 1 2 3 4 5 6 7 8 9 10 11 12 13 14 result 1 2 3 5 8 13 21 34 55 89 144 233 377 610 Enter the data in L1 and L2 in your TI calculator, find the regression line, and construct a scatterplot with the regression line included. Does a line appear to...
Hexadecimal digits are 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C,...
Hexadecimal digits are 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, and F. How many hexadecimal strings of length twelve have five A’s and five B’s? How many hexadecimal strings of length twelve have at most three E’s? How many hexadecimal strings of length twelve have exactly three A’s and at least two B’s? How many hexadecimal strings of length twelve have exactly two A’s and exactly two B’s, so that the two...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT