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

Write a function in Matlab that takes as input s and a number x and outputs the

ID: 3846860 • Letter: W

Question

Write a function in Matlab that takes as input s and a number x and outputs the floating point number of x using s-digit rounding. You may use Matlab’s “round” command to help you. Use only basic programming.

(a) Write out or print out your function

(b) Choose 2 random vectors of length 10, using the “rand” command, and compute the result of the dot product using your function under 4-digit rounding and compute the exact Matlab result and compute the absolute error. Do the same thing 4 more times and turn in the results.

Explanation / Answer

function [m,s] = stat2(x) n = length(x); m = avg(x,n); s = sqrt(sum((x-m).^2/n)); end function m = avg(x,n) m = sum(x)/n; rand();n end

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote