Edit the following MATLAB code using interpolation Write a h
Edit the following MATLAB code using interpolation
Write a helper function, time_resample, that will be useful for other problems in this section. Your function should take as input \" t, a time vector of the form t1: step: t2 \" factor, a positive integer that indicates the factor by which to interpolate the time vector The output should be *tout, a vector that exactly matches the values of t on every factor^th time sample, and linearly interpolates these values for the other samples. The resulting vector should have the same starting and ending values as t. That is, your result should satisfy tout (1) = t(1), tout (1+factor) = t(2), and so on, with correctly interpolated values in between. MATLAB\'s interp1 function may be helpful, but remember to look carefully at the output to make sure it\'s the correct length and doesn\'t contain inaccurate/NaN values.Solution
Solution :
The following function will linearly interpolate the time vector tin to tout .
%*********************************
function tout = time_resample(tin, factor)
len = length(tin);
tout = zeros((len-1)*(factor)+len-1 , 1);
for i=1:len-1
for j=1:factor
tout((i-1)*(factor+1)+j) = tin(i) + ((((tin(2) - tin(1))/(factor+1))*(j)));
end
end
tout= [ tin(1) tout.\'];
k=1;
for i=1 : factor+1 : length(tout)
tout(i) = tin(k);
k=k+1;
end

