interpolate text file data onto different time axis
Mostrar comentarios más antiguos
Hello,
I have a text file which when imported creates a 226 x 2 matrix, with time being the (:,1) and SSH being (:,2). I want to compare and plot this data on some data I have created which is on a 723 x 1 axis. I have tried interp1 and I keep getting all NaN's apart from a few numbers here:
interp1(data(:,1), data(:,2), createddata) so like interp1(226x1, 226x1, 723x1)
I also tried making my own xaxis (1:723) and trying that but it didn't work...
Can someone help me?
thanks in advance! Michael
7 comentarios
Michael
el 28 de Jul. de 2014
dpb
el 28 de Jul. de 2014
Show a short snippet of the data or at least indicate what format the times are in...a little tough w/ no info to say specifically what could be wrong.
Michael
el 28 de Jul. de 2014
Michael
el 28 de Jul. de 2014
Michael
el 28 de Jul. de 2014
Michael Haderlein
el 28 de Jul. de 2014
Your createddata vector is 1:723? As all numbers in the first column (=x) are outside the interval 1:723, it's clear that you only get NaNs. You need to provide times at your createddata vector.
Michael
el 28 de Jul. de 2014
Respuesta aceptada
Más respuestas (2)
Star Strider
el 28 de Jul. de 2014
If you’re getting NaN values from interp1, you are probably extrapolating.
Change your call to interp1 to:
ynew = interp1(data(:,1), data(:,2), createddata, 'linear', 'extrap');
and see if that does what you want. (Change ‘ynew’ to your own variable. I used it here simply to complete the line correctly.)
Michael
el 28 de Jul. de 2014
0 votos
Categorías
Más información sobre Random Number Generation en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!