Interp1 grid vectors must contain unique points
Ältere Kommentare anzeigen
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 Kommentare
Harriet Branson
am 21 Mai 2018
Adam
am 21 Mai 2018
It depends if you are using unique correctly I guess.
Walter Roberson
am 21 Mai 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?
Antworten (0)
Kategorien
Mehr zu Interpolation finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!