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

Write a matlab function m-file Check1(Xin) that takes an array Xin as input and

ID: 1856152 • Letter: W

Question

Write a matlab function m-file Check1(Xin) that takes an array Xin as input and returns an output array Xout such that the output contains the deviation of the input data from the mean of the range. Additionally, any deviation with a magnitude more than the average value is replaced by a zero. That is, if the mean of the data array, then - Xout = 0 if (Xin - mean1) is either larger than (+mean1) or smaller than (-mean1) - Xout = Xin - mean1, otherwise Do not use any Matlab built-in function like length, size or mean. Use a for loop to find the mean of the array.

Explanation / Answer

function [ xout ] = check1( xin ) %Check1 Gives a deviation of input data from the mean % Matlab function m-file Check1(Xin) takes an array Xin as input % and returns an output array Xout such that the output contains the % deviation of the input data from the mean of the range. Additionally, % any deviation with a magnitude more than the average value is replaced % by a zero. That is, if mean1 is the mean of the data array, then % Xout = 0 if (Xin ?mean1) is either larger than (+mean1) or % smaller than (-mean1) % Xout = Xin ?mean1, otherwise sumx = 0; % Initialize the sum numx = 0; % initialize the counter for k = xin % find number of components and numx = numx+1; % the total sum of components sumx = sumx + k; end mean1 = (sumx./ numx); xout = xin - mean1; n = 0; % initialize new counter for x = xout n=n+1; % update counter if (x > mean1) xout(1,n) = 0; elseif (x < -mean1) xout(1,n) = 0; else xout(1,n) = xout(1,n); end end 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