Please help me the question 3 in detail.... this is the matlab question. 1. In o
ID: 2248051 • Letter: P
Question
Please help me the question 3 in detail.... this is the matlab question.
1. In order to find the sum of the first n terms of the harmonic series, 1+1+1+11+ one can display each term as vector element and use build-in function sum. for example, the sum of first 10 terms is obtained; >>harmonic [1./(1:1o) harmonic- 1.0000 0.5000 0.3333 0.2500 0.2000 0.1667 0.1429 0.1250 0.1111 0.1000 >>sum(harmonic) ans 2.9290 Find the sum of the first 50 terms of the geometric series, 1+1+14by applying the above method 2 4 816 2. Find the following sum by first creating vectors for the numerators and denominators: 1 2 3 4 The two vectors, x=[0,-4, 7, 0,-1, 2], y=[1,-4, 8, 0, 1, 6] are given. Explain the following logical operations 3. z = x and (not Y) z= x and y or (not x) z =(x is smaller or equal to 0) and (y is larger than 0) z= (x is smaller than y) or (x is larger than y) a, c. b, d.Explanation / Answer
1) For the geometric series use the following command:
ge=[1./(2.^(0:49))];
Concept:first generate numbers from 0 to 49, net counting is 50. then, take elementwise power of 2 and lastly take the elementwise inverse
and for sum use
sum(ge)
answer is 2
2) the fraction can be written as: (2n+1)/n;
use the following command to take the sum:
for i=1:4
x(i)=(2*i+1)/i;
end
sum(x)
3) Matlab performs all the logical functions as elementwise binary and, not, or operations.
i.e. for logical AND if the value of the 2 matrix at particular index is equal then output is 1 otherwise 0.
for logical OR if the value of the 2 matrix at particular index is equal then output is 0 otherwise 1.
for logical NOT if the value of the matrix at particular index is 0 then its output is 1 otherwise 0.
the commands for the questions are as follows:
a) z=and(x,not(y))
b) z=or(and(x,y),not(x))
c) z=and(x<=0,y>=0)
d) z=or(x<y,x>y)