Hi everybody,
I have a problem regarding data processing in python. Assuming we have two sets of data (x1, y1 and x2, y2), both have different points and spacing. For example:
x1=[4, 3, 2.5, 2, 1, -1, -1.5, -2, -4]
y1=[1, 0.8, 0.7, 0.5, 0.3, 0, -0.3, -0.6, -0.9]
x2=[5, 3, 2, 1, -1, -1.5, -5]
y2=[2, 1.8, 1, 0, 0.2, -0.5, -1.5, 2.5]
How to subtract y1
from y2
?
y3=y2-y1
So far I have tried to use interpolate to first get y1_new
, which represents y1
in x2
:
y1_new = y1 = np.interp(x2,x1,y1)
Thanks in advance.