Write a Matlab code implementing the function which gets as an argument a vector
ID: 3854027 • Letter: W
Question
Write a Matlab code implementing the function which gets as an argument a vector of scalar values X = [xi] for i = 0, 1, 2, .., n, which returns as a result the value of the expression: Group A: v = Sigma^n_i = 0 (Product^n_j = 0, j notequalto 1 x^2_i e^xj) Group B: z = Product^n_j = 0 (Sigma^n_i = 0, j notequalto sin(x^2_i) cos(x_j)). Write a Matlab code implementing the program which will calculate the value of the given integral using composite Simpsons rule with 9 subintervals (10 evaluation points of the integrated function): Group A I = integral^3_-1 e^-2t^2 sin(t) dt Group B: I = integral^3_0 -e^(t^-1) cos(t) dtExplanation / Answer
Am sorry but, Chegg restricts us to answer 1question at a time, so am unable to answer question 5
Answers to question 4 are given below:
function result = answer4a(x)
n = numel(x); //find number of elements
result = 0;
for j=1:n %outer sum loop
product = 1;
for i=1:n %inner product loop
if i == j
continue;
end
product = product * x(i)^2 * exp(x(j));
end
result = result + product;
end
end
function result = answer4b(x)
n = numel(x);
result = 1;
for j=1:n %outer product loop
sum = 0;
for i= 1 : n %inner sum loop
if i == j
continue;
end
sum = sum + sin(x(i)^2)*cos(x(j));
end
result = result * sum;
end
end
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.