Matlab homework. 6. Create a vector x with the elements xn = (-1)n+1/(2n-1 ) Add
ID: 3873465 • Letter: M
Question
Matlab homework.
6. Create a vector x with the elements xn = (-1)n+1/(2n-1 ) Add up the elements of the version of this vector that has 100 elements 7. Write down the MATLAB expression(s) that will a.... compute the length of the hypotenuse of a right triangle given the lengths of the sides (try to do this for a vector of side-length values) b.... compute the length of the third side of a triangle given the lengths of the other two sides, given the cosine rule c2 - a2 + b2 -2(a)(b)cos(t) where t is the included angle between the given sides 8. Given a vector, t, of length n, write down the MATLAB expressions that will correctly compute the following a. In(2 +ttt b. e(1cos(3t) c. cos2(t)sin?(t) d. tan (A) (this is the inverse tangent function) e. cot(t) f. sec2(t) + cot(t) -1 Test that your solution works for t = 1:0.2:2 9. Plot the functions X, X3, ex and ex-over the interval 0Explanation / Answer
Matlab codes for the questios:
%1) Create a vector of the even whole numbers between 31 and 75.
clc;
v = []; %vector to store the even whole numbers between 31 and 75
for i = 31:75
if(mod(i,2) == 0)
v = [v,i];
end
end
v
%6)
n = 100;
v = []; %vector to store the values in the sequence
for i = 1:n
tn = ((-1)^(i+1))/(2*i - 1);
v = [v,tn];
end
summ = sum(v)
%7) a
sides = [3,4]; % vector to store lenghts of sides
hypotenuse_lenght = sqrt( (sides(1))^2 + (sides(2))^2 )
%7) b
a = 4; %set length of side 1
b = 3; %set length of side 2
angle = 90;%set angle between sides
c = sqrt(a^2 + b^2 - 2*a*b*cosd(angle)) %calculate length of third side
Note that you have posted multiple questions, I have answered intial 4 subparts according to chegg rules!