3, Let x = [3 2 6 8]\' and y = [4 1 3 5]\"(NB. x and y should be column vectors)
ID: 3873551 • Letter: 3
Question
3, Let x = [3 2 6 8]' and y = [4 1 3 5]"(NB. x and y should be column vectors). a. Add the sum of the elements in x to y b. Raise each element of x to the power specified by the corresponding element in y c. Divide each element of y by the corresponding element in x d. Multiply each element in x by the corresponding element in y, calling the result "Z" e. Add up the elements in z and assign the result to a variable called "w". f. Compute xy - w and interpret the result 5. Create a vector x with the elements a, 2, 4, 6, 8, … b. 10, 8, 6,4, 2, 0, -2,-4 C. 1, 112, 1/3, 1/4, 1/5, … d. 0, 1/2, 2/3, 3/4, 4/5,Explanation / Answer
clc;
x = [3 2 6 8];
y = [4 1 3 5];
%[a]
sumA = sum(x);
y = y + sumA;
disp(y)
%[b]
disp('Power')
for i = 1 : length(x)
disp(x(i).^y(i))
end
%[c]
disp('Division')
for i = 1 : length(x)
disp(y(i)./x(i))
end
%[d]
disp('Multi')
for i = 1 : length(x)
z(i) = x(i)*y(i);
end
disp(z)
%[e]
w = sum(z);
%[f]
for i = 1 : length(x)
disp(x(i)*y(i) - w)
end
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.