MATLAB For each of the following write a loops that is equiv

MATLAB

For each of the following write a loop(s) that is equivalent to the expression. Note that \"x\" is a vector with at least 30 elements. sigma_i = 1, 3, 5..., ^30 sigma_j = 2^21 [(i middot x_i) + (j middot x_i + 1)^3 + 2] Product_k = 2^7 x_k sigma_m = 1^3 m middot k middot x_m

Solution

%summation
x = 1:1:32;
sum = 0;
for i = 1:2:30
    for j = 2:1:21
        sum = sum + i*x(i) + (j*x(i+1)).^3 + 2;
    end
end
disp([\'Sum of the expression is: \',num2str(sum)]);

%product
x = 1:1:32;
prod = 1;
grandsum = 0;
for k = 2:1:7
    sum = 0;
    for m = 1:1:3
        sum = sum + m * k * x(m);
    end
    prod = prod * x(k) * sum;
end
disp([\'Result of the expression of product of sums is: \',num2str(prod)]);

MATLAB For each of the following write a loop(s) that is equivalent to the expression. Note that \

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site