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

coursework mathworks.com Solve Problem Cody Coursework qiuning ge V hwy 10 Read

ID: 3832740 • Letter: C

Question

coursework mathworks.com Solve Problem Cody Coursework qiuning ge V hwy 10 Read a column of numbers and interpolate missing data Problem Description lam introducing a simpler version of this problem more appropriate to the course. You only need to complete one of these problems for full credit on hw10 Given an input cell array of strings s pick out the second column and turn it into a row vector of data. Missing data will be indicated by the number 9999. If you encounter missing data, you should perform linear interpolation to the nearest accurate data points (missing data will not occur in the first or last element). The first row is always descriptive text. So if the input cell array sis Day Temp 1 -5 2 19 4 9999 5 3 then the output variable t is the following row vector. t s I-5 19 1 2 31: Here's an example of real-world data. MacBook Air

Explanation / Answer

function t = read_and_interp(s)

[token, remain] = strtok(s)

x = str2double(token);
x(1, :) = [];

y = str2double(remain);
y(1, :) = [];

for i = 1: length(y)
if y(i) == 9999
y(i) = NaN;
else
y(i) = y(i)
end
end

t=y;

bd=isnan(y);
gd=find(~bd);
bd([1:(min(gd)-1) (max(gd)+1):end])=0;
t(bd)=interp1(gd,y(gd),find(bd));
end

s= {...
'Day Temp'
'1 1.3'
'2 1.12'
'3 17'
'4 16'
'5 9999'
'6 9999'
'7 19'};
t = read_and_interp(s);
disp(t')