Search code examples
matlabinverse

Invert a series of data as if inverting a function using MATLAB


Is it possible to "invert" a series of data like when a function is inverted?

Let me explain. If I have a function that I can plot in MATLAB, I can always (almost) find the inverse of such function with the finverse and the plot would provide this:

Enter image description here

But I do not have the a function for my data, and I would still like to find a sort of inverse of such series of data, like for example y=f(x) where

x=[0.0050879   0.0056528   0.0062176   0.0067822   0.0073467   0.0079111   0.0084752   0.0090392   0.0096030   0.0101666   0.0107299   0.0112930   0.0118558   0.0124184   0.0129807   0.0135428   0.0141045   0.0146659   0.0152270   0.0157877   0.0163481];

and

y=[0.0000e+00   0.0000e+00   0.0000e+00   0.0000e+00   0.0000e+00   0.0000e+00   0.0000e+00   0.0000e+00   0.0000e+00   0.0000e+00   4.4901e-05   4.4901e-05   8.9801e-05   1.3470e-04   1.7960e-04   2.2450e-04   2.6940e-04   3.5920e-04   4.0411e-04   4.9391e-04   5.8371e-04];

Is this kind of operation on a series of data possible in MATLAB? Is there a technique/method/function that handles this?

NOTE: I previously tried to "fit" the series of data with a polynomial via the polyfit function and then invert it via the finverse function; but it results in an f^-1 function that is dependent on both x and y at the same time. And because x is not even spaced homogeneously, I do not even know how to plot it...


Solution

  • Inverting a function represented by a series of (x, y) data points is done by changing the position of x and y: (y, x). This can be visualised in Matlab as follows:

    figure
    hold on
    plot(x, y, 'red')
    plot(y, x, 'blue')
    from = min(min(x), min(y));
    to = max(max(x), max(y));
    plot([from to], [from to], 'k--')
    legend('Original', 'Inverted')
    

    enter image description here