X010a Create a matrix called test of size 2x2 such that the

X=[0:10(a) Create a matrix called test of size 2x2 such that the elements of the matrix test are test(i, j) = (i^2 - j). Use the command window statements to create this matrix. Use the keyboard to alter the value of test(1, 2) to -5 and test(2, 2) to 20 What is the value of test(3)? What does this represent? What is the value of test(5)? Why does this give an error message? Why do test (2, 2) and test (4) yield the same value? Add a row to test so that the last row of test contains the entries 2, 9 Create a 1x2 matrix called test 1 whose elements are 12 and 14. Concatenate test 1 with test. Use the cat function to add another column to test. The elements of this new column are 4, 3, and 7

Solution

(a)

%(a) creating 2 by 2 test matrix

for i=1:2

for j=1:2

test(i,j)=i^2-j;

end

end

test

test(1,2)=-5;

test(2,2)=20;

test

(b)

test(3)=-5 (Since third element matrix is -5 or actual index test(2,1) so 2+1=3, test(3)=-5).

test(5) displays error message because it contains only 4 elements.

test(2,2) and test(4) both are same because index (2,2) means (2+2)=4. so test(2,2)=test(4)

(c)

test(3,1)=2;
test(3,2)=9;

(d)

test1=[12 14];
test=[test; test1]

 X=[0:10(a) Create a matrix called test of size 2x2 such that the elements of the matrix test are test(i, j) = (i^2 - j). Use the command window statements to c

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site