How do I compare two graphs for X value at a specific point?

40 views (last 30 days)
I have two dataset that gives plots as below. My goal is to match them and get the x value at a certain point. I have been trying interpolation but isn't getting the result I want. Your help is appreciated.
  5 Comments
dpb
dpb on 28 Mar 2021
Well, you'll have to define what is the end point of the experimental data -- is the last measured point a normalized value of 1.0 or something less since your other figure only goes to 0.9?
Then, you've got a problem in that 7.1/7.8 --> 0.91 for the relative range of your observations whereas the other variable range i covers nearly the full range, so it certainly isn't just a relative ratio.
Tell us exactly what you think your expected result should be here.
Then attach the data for the curves as a .mat file would help immensely for anybody to do anything; otherwise have to try to make up data besides...
Star Strider
Star Strider on 28 Mar 2021
The plots in the two images not only appear to have no independent or dependent variable values in common, they actually appear to orders-of-magnitude different.

Sign in to comment.

Accepted Answer

dpb
dpb on 28 Mar 2021
Edited: dpb on 28 Mar 2021
Well, as Star Strider says, the disparity in orders of magnitude between the two makes one truly wonder just how they're supposed to have been related to each other somehow -- but, presuming there is some reason it might make sense, here's the simplest stab at it --
[b,S,mu]=polyfit(ind,refVt5,9); % NB: badly scaled, a 9th deg polynomial is very sensitive
tiledlayout(2,1),hAx=nexttile,plot(ind,refVt5) % plot raw data first
hAx.YDir="reverse";
ylim([2.2 2.7])
Vhat=polyval(b,ind,S,mu); % evaluate the polynomial on refV
hold(hAx,'on');hL=plot(hAx,ind,Vhat,'.r'); % add to the plot
hAx(2)=nexttile;
plot(XX,YY)
% the engine
Xhat=interp1([XX(1);XX(end)],[ind(1);ind(end)],XX); % scale standard curve ranges to
Yhat=interp1([YY(1);YY(end)],[Vhat(1);Vhat(end)],YY); % those of experimental data
hL(2)=plot(hAx(1),Xhat,Yhat,'.k-'); % plot on top of experimental data
legend(hAx(1),'refVt5','fitVt5','Scaled STD')
results in
There a little similarity in that both are concave, but that's about as much as can be said for a linear scaling.
Is there any physical model that could be used to predict some functional form that could aid in justifying some nonlinear scaling operation?
  4 Comments
dpb
dpb on 28 Mar 2021
Edited: dpb on 29 Mar 2021
That would just be interpolating the other direction from ind to XX instead of XX to ind on abscissa and, apparently, not scaling the ordinate (y) values.
And, of course, that the actual experimental curve data is concave downward rather than upward as is the STD curve complicates matters -- the scaling operation above does the implicit change in axes direction internally with the transformation/scaling of the data.
Some idea of why that is so might make for more satisfying way to approach the problem.
dpb
dpb on 28 Mar 2021
Edited: dpb on 28 Mar 2021
"the actual experimental curve data is concave downward rather than upward"
One way one might deal with that would be something like --
refVt5Flip=refVt5-refVt5(1); % difference from first point of curve
refVt5Flip=refVt5(1)-refVt5Flip; % switch sign difference relative first point
will give the reflection of the original curve about the initial point in the y direction. Then can plot both curves on same axes with same curvature.
Again, it is totally unknown as to whether any of this makes any sense to do or not with no klew about what these data might represent and, therefore, why such a reflection might be expected as well as the tremendous scale factor differences.
If I do that on the lower of the two previous plots, the result is\
which makes the two look more similar in shape on the larger scale y axes. One might then try simply computing the mean difference between the two and using that to adjust one or the other.
This again, of course, still uses the linear transformation/scaling of the x axis to get the two on the same scale with all the assumptions that implies.

Sign in to comment.

More Answers (0)

Categories

Find more on 2-D and 3-D Plots in Help Center and File Exchange

Products


Release

R2020a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!