These are all MATLAB questions. Please help me the answer in detail. In order to
ID: 2247978 • Letter: T
Question
These are all MATLAB questions. Please help me the answer in detail.
In order to find the sum of the first n terms of the harmonic series, 1+1+1+1+1+ one can display each term as vector element and use build-in function sum. for example, the sum of first 10 terms is obtained; 1. >> harmonics(1/(1:10)! 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+1.11.+.by applying the above method. 2 4 8 16 2. Find the following sum by first creating vectors for the numerators and denominators 3 5 7 9 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) (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
Answer for question 1:
>> n = 0:49;
>> harmonic = (1/2).^n;% 1/2 will be raised by power of each element of n and .^ is for element by element operation
>> harmonic
harmonic =
Columns 1 through 10
1.0000 0.5000 0.2500 0.1250 0.0625 0.0313 0.0156 0.0078 0.0039 0.0020
Columns 11 through 20
0.0010 0.0005 0.0002 0.0001 0.0001 0.0000 0.0000 0.0000 0.0000 0.0000
Columns 21 through 30
0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000
Columns 31 through 40
0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000
Columns 41 through 50
0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000
>> sum(harmonic)%gives the required sum
Answer for question 2:
>> num = [3 5 7 9]
num =
3 5 7 9
>> den = [1 2 3 4]
den =
1 2 3 4
>> num./den% each element in num will be divided by corresponding element in den
ans =
3.0000 2.5000 2.3333 2.2500
>> sum(ans)
ans =
10.0833
>>
ans =
2.0000
>>
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.