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

조회 수: 29 (최근 30일)
Ashik Rahman
Ashik Rahman 2021년 3월 27일
편집: Ashik Rahman 2021년 4월 1일
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
dpb
dpb 2021년 3월 28일
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 2021년 3월 28일
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.

댓글을 달려면 로그인하십시오.

채택된 답변

dpb
dpb 2021년 3월 28일
편집: dpb 2021년 3월 28일
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
dpb
dpb 2021년 3월 28일
편집: dpb 2021년 3월 29일
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 2021년 3월 28일
편집: dpb 2021년 3월 28일
"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.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

제품


릴리스

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by