- If v is a vector, then length(x) must equal length(v).
- If v is an array, then length(x) must equal size(v,1).
How to interpolate data
    8 views (last 30 days)
  
       Show older comments
    
Hello,
P=[NaN	NaN	NaN	163.626652810406	140.245221578496	143.291946126177	158.198843187782	179.073274059170	206.654075204109	255.461365237779	318.955295177489	396.993670297888	486.124439415540	587.818128810315	703.723462252509	831.059610098512	974.884947235331	1136.56020938783	NaN	NaN] : it is 1*20 double
V= [148.527280000000	166.471365263158	184.415450526316	202.359535789474	220.303621052632	238.247706315790	256.191791578947	274.135876842105	292.079962105263	310.024047368421	327.968132631579	345.912217894737	363.856303157895	381.800388421053	399.744473684211	417.688558947368	435.632644210526	453.576729473684	471.520814736842	489.464900000000] : it is also 1*20 double
I want to know the specific V data when P is 500.
I try to use 
V_specific = interp1(P,V,500);
but there is error message, I don't know what is the problem.
is there any methods to solve this problem? 
Thanks
0 Comments
Answers (2)
  Sylvain
      
 on 9 Nov 2020
        Input Arguments
x — Sample points
vector
Sample points, specified as a row or column vector of real numbers. The values in x must be distinct. The length of x must conform to one of the following requirements:
Example: [1 2 3 4 5 6 7 8 9 10]
Example: 1:10
Example: [3 7 11 15 19 23 27 31]'
Data Types: single | double | duration | datetime
Thus remove the NaN values: 
V_specific = interp1(P(4:end-3),V(4:end-3),500)
0 Comments
  Mathieu NOE
      
 on 9 Nov 2020
        hi
get rid of the NaN
ind_not_NaN = ~isnan(P);
V_specific = interp1(P(ind_not_NaN),V(ind_not_NaN),500);
0 Comments
See Also
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!

