Problems In this lab, we will use MATLAB to solve a variety of problems. 1. Vect
ID: 3785725 • Letter: P
Question
Problems In this lab, we will use MATLAB to solve a variety of problems. 1. Vector Manipulation (40 points) Use MATLAB to generate a row vector A and a column vector B of the same size specified by the user. Both A and B contain as elements random integers from 0 to 100. Calculate the following quantities: (a) The sum of A and B (b) A minus B. (c) The inner product of A and B. (d) The outer product of A and B. For a b, implement the calculations using both a for loop and MATLAB vector operations. For d, implement using MATLAB vector operations. 2. Solving a linear system of equations (20 points) Use MATLAB to solve the following system of linear equations 28 118 2 176 451TA 236z5 56 120 103r3+ 271r4 287 112 235r2 313r3 874T4 398r 5 470r2-t 626r3+ 1688 733T5 224T1Explanation / Answer
Que1
a)
Matlab code:
Using matlab functions:
n = input('Input size of the column vector ');
A = randi(100,1,n)
B = randi(100,n,1)
Summ = A + B'
Using for loop:
n = input('Input size of the column vector ');
A = randi(100,1,n)
B = randi(100,n,1)
for i = 1:n
Summ(i) = A(i) + B(i);
end
Summ
b)
Using matlab function:
n = input('Input size of the column vector ');
A = randi(100,1,n)
B = randi(100,n,1)
Diff = A - B'
Using for loop:
n = input('Input size of the column vector ');
A = randi(100,1,n)
B = randi(100,n,1)
for i = 1:n
Diff(i) = A(i) - B(i);
end
Diff
c)
n = input('Input size of the column vector ');
A = randi(100,1,n)
B = randi(100,n,1)
Inner_prod = A*B
d)
n = input('Input size of the column vector ');
A = randi(100,1,n)
B = randi(100,n,1)
Outer_product = B*A
Please note that you have posted multiple questions, so according to chegg rules I will be answering initial 4 subparts only.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.