Please use MATLAB to solve the following problems Be sure to
Please use MATLAB to solve the following problems. Be sure to include well detailed comments so that I can understand all functions and processes. Be sure to answer all problems. Thanks in advance.
Problems In this lab, use MATLAB. You must implement all functions. 2. Polynomial Evaluation (30 points) This function called polyeval takes as parameters a polynomial representation as an array and a number to evaluate. For example, if the first parameter passed is -4 013 6, it represents 4 13r2 6a3. For the second parameter, if 3 is passed, then a for loop can be used to calculate the value as follows -4 3 0 31 13 32 6 33. The function returns the result of the evaluation. 3. Congruence (30 points) Implement a function called Congruent which returns True if E b (mod m) meaning a is congruent to b (mod m) else it returns False. The condition for it to be true is when a (mod m) b (mod m) The funtion takes only 3 input parameters ab and m. The function should ensure that m is a positive integer. Give two test examples that returns True and two that returns False.Solution
2.
function value = polyeval(arr, x)
value = 0;
for i = 1:numel(arr)
value = value + arr(i) * x^(i - 1);
end
3.
function value = Congruent(a, b, m)
if mod(a, m) == mod(b, m)
value = true;
else
value = false;
end
Congruent(4, 10, 3)
Congruent(2, 11, 3)
Congruent(4, 9, 3)
Congruent(4, 11, 3)
