This is working still would be appreciated for enhancement.
function t = read_and_interp(s)
s=strtrim(s);
row_num=numel(s);
counter=1;
for i=2:row_num
splitted=strsplit(s{i});
temp1=splitted(1);
temp2=splitted(2);
r(counter)=str2double(temp1);
r(counter+1)=str2double(temp2);
counter=counter+2;
end
first_column=r(1:2:end)
second_column=r(2:2:end)
if find(second_column==9999)>=1
first_column(find(second_column==9999))=[];
missed=find(second_column==9999);
second_column(find(second_column==9999))=[];
missed_value=interp1(first_column,second_column,missed)
second_column=r(2:2:end);
second_column(find(second_column==9999))=missed_value;
t=second_column
else
t=second_column
end
Test 1 is problematic. It does not accept the answer like 2.4000, 2.400, or 2.40. It expects exactly 2.4 which is the same. There is something wrong about test 1 format or something. Please update test 1.