Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Please Help using Matlab.. Problem 1 For the arrays x and y given below, use MAT

ID: 3886399 • Letter: P

Question

Please Help using Matlab..

Problem 1 For the arrays x and y given below, use MATLAB to find all the elements in x that are greater than the corresponding elements in y. x=-3, 0, 0, 2, 6, 8] y =-5,-2, 0, 3, 4, 10] Problem 2 The arrays PriceA and PriceB given below contain the price in dollars of two stocks over 10 days. Use MATLAB to determine how many days the price of stock A was above the price of stock B. PriceA 19, 18, 22, 21, 25, 19, 17, 21, 27, 29] Prices [22, 17, 20, 19, 24, 18, 16, 25, 28, 27) Problem:3 The arrays PriceA, PriceB, and Pricec given below contain the price in dollars of three stocks over 10 days. a. Use MATLAB to determine how many days the price of stock A was above both the price of stock B and the price of stock C. b. Use MATLAB to determine how many days the price of stock A was above either the price of stock B or the price of stock C c. Use MATLAB to determine how many days the price of stock A was above either the price of stock B or the price of stock C, but not both.

Explanation / Answer

% declaring 2 arrays given
x = [-3, 0, 0, 2, 6, 8];
y = [-5,-2, 0, 3, 4, 10];

% looping through each element in x
% comparing with corresponding element in y
% printing if it is greater
for i=1:length(x)
if x(i)>y(i)
fprintf("%d ",x(i))
end
end

Sample Output

-3 0 6

% declaring 2 arrays given
x = [-3, 0, 0, 2, 6, 8];
y = [-5,-2, 0, 3, 4, 10];

% looping through each element in x
% comparing with corresponding element in y
% printing if it is greater
for i=1:length(x)
if x(i)>y(i)
fprintf("%d ",x(i))
end
end

Sample Output

-3 0 6