Question

In: Computer Science

Make a 20 by 20 matrix in which diagonal elements are 2, 5, 8, 11 ......

Make a 20 by 20 matrix in which diagonal elements are 2, 5, 8, 11 ... 59 and the first column is 21,22,23,24 ... 40 whereas the rest of the elements of the matrix are 9.

Note: you must if, elseif, else, end or/and if, end or/and if, else, end commands in MATLAB.

Solutions

Expert Solution

Thanks for the question. Below is the code you will be needing. Let me know if you have any doubts or if you need anything to change.

If you are satisfied with the solution, please leave a +ve feedback : ) Let me know for any help with any other questions.

Thank You!
===========================================================================

matrix = zeros(20,20);

for i = 1: 20
for j = 1: 20
if j==1
matrix(i,j) = 2*i;
elseif i==1 & j==1
matrix(i,j) = 2;
elseif i==j
matrix(i,j) = matrix(i-1,j-1)+3;
else
matrix(i,j) = 1;
end
end   
end
matrix

=====================================================================


Related Solutions

Make a 20 by 20 matrix in which diagonal elements are 21, 22, 23, 24 …...
Make a 20 by 20 matrix in which diagonal elements are 21, 22, 23, 24 … 40 and elements below the diagnol are ij = 2(i 2 j 2 ) and elements above the diagnol are 4×(i+j) Note: You must use if, elseif, else, end or/and if, end or/and if, else, end commands in MATLAB.
Consider an orthogonal matrix Q ∈ R ^m×m and a diagonal matrix with non-zero diagonal elements...
Consider an orthogonal matrix Q ∈ R ^m×m and a diagonal matrix with non-zero diagonal elements D ∈ R^ m×m and answer the True— False questions below. (k) Any vector x ∈ R^m can be written as a linear combination of the columns of D (l) The columns of Q span R^m (m) The columns of D span R^m (n) The columns of Q are a basis for R^m (o) The columns of D are a basis for R^m
(2) A matrix A is given. Find, if possible, an invertible matrix P and a diagonal...
(2) A matrix A is given. Find, if possible, an invertible matrix P and a diagonal matrix D such that P −1AP = D. Otherwise, explain why A is not diagonalizable. (a) A =   −3 0 −5                 0 2 0                 2 0 3 (b) A =   2 0 −1              1 3 −1              2 0 5 (c) A = 1 −1 2              −1 1 2               2 2 2
Given the data set A = {5, 4, 6, 14, 2, 2, 11, 4, 5, 8,...
Given the data set A = {5, 4, 6, 14, 2, 2, 11, 4, 5, 8, 3, 1, 12, 15, 13}, which is the data of a sample taken from a larger population. Calculate the arithmetic mean Find the median Find the mode Calculate the range Calculate the interquartile range Calculate the mean deviation Calculate the variance Calculate the standard deviation
Calculate and interpret a 95% confidence interval 5, 5, 2, 11, 1, 5, 3, 8, 5,...
Calculate and interpret a 95% confidence interval 5, 5, 2, 11, 1, 5, 3, 8, 5, 4, 7, 2, 9, 4, 8, 10, 4, 5, 6, 6
Matrix A2= [1 2 3; 4 5 6; 7 8 9; 3 2 4; 6 5...
Matrix A2= [1 2 3; 4 5 6; 7 8 9; 3 2 4; 6 5 4; 9 8 7] Note: TA2 is defined to be a linear transformation that maps any vector x to A2* x. That is TA2 = A2*x. Also the range of the Linear transformation represented by A2 is the same as the column space of A2. l) Find a basis for the null(TA2). m) Find nullity of A2, TA2 and A2tA2. n) Find rank(A2), rank(A2t),...
Shoe Size 12 6 11 13 8 9 8 8 9 9 11 5 10 8...
Shoe Size 12 6 11 13 8 9 8 8 9 9 11 5 10 8 7 7 11 9 9 9 12 8 8 8 12 9 11 8 11 8 13 5 9 8 11 We need to find the confidence interval for the SHOE SIZE variable. To do this, we need to find the mean and standard deviation with the Week 1 spreadsheet. Then we can the Week 5 spreadsheet to find the confidence interval. This does...
MATLAB: Matrix M = [ 0 2 3 5; 7 3 8 4 ] Write one...
MATLAB: Matrix M = [ 0 2 3 5; 7 3 8 4 ] Write one command that stores all of the rows of columns 1, 2, and 3 of M into a matrix named M2.
5. (20%) Suppose we have an array int a [8] = {1, 2, 3, 5, 6};...
5. (20%) Suppose we have an array int a [8] = {1, 2, 3, 5, 6}; and we also have a linked list L of 5 entries 1 -> 2 -> 3 -> 5 -> 6, where 1 is the first in the linked list L, followed by 2 etc. We want to put a new item 4 between 3 and 5 in the array a and in the linked list L (a) Explain in plain English how you do...
Consider the matrix list x = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]. Write...
Consider the matrix list x = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]. Write a list comprehension to extract the first column of the matrix [1, 4, 7]. Write another list comprehension to create a vector of twice the square of the middle column.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT