Interp1 grid vectors must contain unique points
Show older comments
I have a time series of daily temperature and rainfall data from 1880 to 2018, which I am trying to interpolate. It returns the error 'grid vectors must contain unique points', and I used the unique function before, which basically removed over 50,000 data points from each dataset. Is there any way to remove the duplicate values without changing my entire dataset? I inserted the code for my interpolation in case this is the problem. All the date values are Matlab datenumbers.
% Linear
sheffDailyMaxTemp_interp_linear = interp1(sheffTempMatlabDate, sheffDailyMaxTemp, min(sheffTempMatlabDate):max(sheffTempMatlabDate),'linear','extrap');
sheffDailyMinTemp_interp_linear = interp1(sheffTempMatlabDate, sheffDailyMinTemp, min(sheffTempMatlabDate):max(sheffTempMatlabDate),'linear','extrap');
sheffDailyRain_interp_linear = interp1(sheffRainMatlabDate, sheffDailyRain, min(sheffRainMatlabDate):max(sheffRainMatlabDate),'linear','extrap');
% pchip
sheffDailyMaxTemp_interp_pchip = interp1(sheffTempMatlabDate, sheffDailyMaxTemp, min(sheffTempMatlabDate):max(sheffTempMatlabDate),'pchip','extrap');
sheffDailyMinTemp_interp_pchip = interp1(sheffTempMatlabDate, sheffDailyMinTemp, min(sheffTempMatlabDate):max(sheffTempMatlabDate),'pchip','extrap');
sheffDailyRain_interp_pchip = interp1(sheffRainMatlabDate, sheffDailyRain, min(sheffRainMatlabDate):max(sheffRainMatlabDate),'pchip','extrap');
% spline
sheffDailyMaxTemp_interp_spline = interp1(sheffTempMatlabDate, sheffDailyMaxTemp, min(sheffTempMatlabDate):max(sheffTempMatlabDate),'spline','extrap');
sheffDailyMinTemp_interp_spline = interp1(sheffTempMatlabDate, sheffDailyMinTemp, min(sheffTempMatlabDate):max(sheffTempMatlabDate),'spline','extrap');
sheffDailyRain_interp_spline = interp1(sheffRainMatlabDate, sheffDailyRain, min(sheffRainMatlabDate):max(sheffRainMatlabDate),'spline','extrap');
4 Comments
Harriet Branson
on 21 May 2018
Adam
on 21 May 2018
It depends if you are using unique correctly I guess.
Walter Roberson
on 21 May 2018
What is the data type of sheffTempMatlabDate ? What are some example values from it? How many unique values are you expecting for it? Is it possible that your time series covers multiple locations so you have multiple data points for each day, one for each location?
Answers (0)
Categories
Find more on Interpolation in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!