Please do question number 3 in MATLAB (include coding) and with all of its items
ID: 2259207 • Letter: P
Question
Please do question number 3 in MATLAB (include coding) and with all of its items (including the create assignments). The value for C is the Multiplication of each element in A by the corresponding element of B, that give us C = 55 91 135 187.
Thank you experts!
3) Let A = [5; 7;9; 11] and B = [11; 13; 15; 17] (column vectors) b. Add the sum of the elements of A to each of the elements of B d. Divide each element in A by the sum of the elements in B f. Add up all the elements in C and assign the result to a variable called D g. Compute A'*B – D and interpret the result (describe why you get to that result). Create a vector x with the following elements: C. 1, 1/2, 1/3, 1/4, 1/5, 1/6, 1/2, 1/8, 1/9, 1/10 d. 0, 1/2, 2/3, 3/4, 4/5, 5/6, 6/7, 7/8, 8/9, 9/10 Create a column vector, called Y, with each element as Y(n) = (-1)n+1/(2n-1) where n refers to the index of the entries (elements) in Y. Add up all the elements of the version of Y that has 200 elements.Explanation / Answer
a)
clc;
clear all;
format short
%Answer a
A=[5;7;9;11]
B=[11;13;15;17]
C=A.*B
%% Answer
A =
5
7
9
11
B =
11
13
15
17
C =
55
91
135
187
b)
A=[5;7;9;11]
B=[11;13;15;17]
C=A.*B
a=sum(A)
b=sum(B)
a+B
ans =
43
45
47
49
d)
A=[5;7;9;11]
B=[11;13;15;17]
C=A.*B
a=sum(A)
b=sum(B)
A./b
ans =
0.0893
0.1250
0.1607
0.1964
f)
A=[5;7;9;11]
B=[11;13;15;17]
C=A.*B
D=sum(C)
D =
468
g)
A=[5;7;9;11]
B=[11;13;15;17]
C=A.*B
D=sum(C)
A'*B-D
ans =
0
% A'*B means sum of multiplication of elemnts that equal to D
g)
clear all
for i=1:10
x(i)=1/i;
end
format rat
x'
ans =
1
1/2
1/3
1/4
1/5
1/6
1/7
1/8
1/9
1/10
d)
clear all
format rat
for i=1:10
x1(i)=(i-1)/i;
end
x1'
ans =
0
1/2
2/3
3/4
4/5
5/6
6/7
7/8
8/9
9/10
clear all
format short
for n=1:200
y(n)=(-1)^(n+1)/(2*n-1);
end
sum(y)
ans =
0.7841