I have generated a simple example with 3 different x-axis. As you can see that each x1,x2 and x3 are stepped differently, starting and ending points are different. My goal is to have a common x-axis from all the three x1,x2 and x3. For which the starting is the minimum among the three and end point is max among all. The new x-axis should be equally stepped. For instance, x=[0,3,6,9,........,36,39] and I need all the y1, y2 and y3 to be interpolated according to the new axis. It should not interpolate beyond its corresponding axis, by this I mean that for y2_new it shouldn't have values at x-axis 36 and 39 because x2 has max value of 34 (elaborated in the following example).
x1 = [0,2,3,7,10,12,17,21,22,39];
y1 = [110,112,113,117,110,122,121,131,156,129];
x2 = [2,7,11,13,17,23,25,34];
y2 = [100,120,129,152,131,128,129,110];
x3 = [1,5,10,14,18,22,29,31,35];
y3 = [80,120,129,142,171,148,119,135,101];
plot(x1,y1)
hold on
plot(x2,y2)
plot(x3,y3)
The final result should be like (length of x,y1_new, y2_new and y3_new is 14)
x = 0:3:39; % length is 14
and the new y's, all must have 14 values
y1_new = ....... contains 14 values
y2_new = [value, value, ......, NaN, NaN] this vector should also contain 14 values but last 2 are NaNs because the max of x2 is 34, no values beyond 34.
y3_new = ....
All these new values must be interpolated versions of y1, y2 and y3.