How to implement linear interpolation in Matlab - Coordinates and dates -
i have csv file contains data of hurricane location coordinates. i'm new matlab i'm not sure how treat correctly date , hour cells, when displayed unconventionally.
i need apply linear interpolation can date every 30 minutes.
let's assume read data in numerical values
now have matrix so:
data = [20130928 0 21.1 50.0 20130928 600 22.2 50.3 20130928 1200 23.3 50.6 20130928 1800 24.2 50.6];
to convert first 2 columns datetime
values, this:
% concatenate first 2 columns, including making times 4 digits 0 padding fulltime = [num2str(data(:,1)), num2str(data(:,2), '%.4u')] % use datetime convert (cell) times dates given format dates = datetime(cellstr(fulltime),'inputformat', 'yyyymmddhhmm'); >> dates = 28-sep-2013 00:00:00 28-sep-2013 06:00:00 28-sep-2013 12:00:00 28-sep-2013 18:00:00
now can interpolate. first create array of times want use:
% data value every 30 mins interpdates = dates(1):hours(0.5):dates(end)
then use interp1
interpolateddata = interp1(dates, data(:,3:4), interpdates); >> interpolateddata = 21.1000 50.0000 21.1917 50.0250 21.2833 50.0500 21.3750 50.0750 ... 24.1250 50.6000 24.2000 50.6000
Comments
Post a Comment