Back-Calculating to Match Previously Established Variable

조회 수: 4 (최근 30일)
Jonathan Pinko
Jonathan Pinko 2020년 3월 4일
댓글: Jonathan Pinko 2020년 3월 12일
Hi All,
In my code, I previously defined a variable:
xFe54=0:.00002:2.5.
I then manipulated this variable extensively, performing the following calculations:
v=zeros(length(xFe54),length(n));
q=zeros(length(xFe54),length(n));
for i=1:numel(xFe54)
for j=1:numel(n)
v(i,j)=(1/n(j)^2)*exp(-n(j)^2*pi^2*xFe54(i));
q(i,j)=(1/n(j)^2)*exp(-n(j)^2*pi^2*fFe56*xFe54(i));
end
end
SumFe56=sum(q,2);
SumFe54=sum(v,2);
BulkFe56=(Fes*alpha)+((6*alpha*(Fe0-Fes))/pi^2)*SumFe56;
BulkFe54=(Fes*omega)+((6*omega*(Fe0-Fes))/pi^2)*SumFe54;
DeltaFe56=(((BulkFe56./BulkFe54)/(alpha/omega))-1)*1000;
Fo = 100-((BulkFe56+BulkFe54)/(alpha+omega));
I then eventually plotted Fo vs. DeltaFe56 (the plot is attached). I then took a set of data points and defined which ones were reasonably close to this curve, via the following code:
xq = dataset(1:116,1);
Feyq = dataset(1:116,2);
Fevq = interp1(Fo,DeltaFe56,xq);
Fezq = Feyq-Fevq;
Feyqlimit = Feyq(Fezq <= abs(.025));
I ultimately generated the following vector:
Feyqlimit =
-.0919
-.0782
-1.7060
-.3630
I would now like to find out what the xFe54 values are that correspond to these data points. As in, these Feyqlimit values are each specific values of DeltaFe56, but what are the respective values of xFe54 that could generate these DeltaFe56 values? Could anyone provide any insight as to how to do this? Please let me know if I could provide more information to make this problem easier.

답변 (1개)

David Goodmanson
David Goodmanson 2020년 3월 4일
편집: David Goodmanson 2020년 3월 4일
Hi Jonathan,
you don't show the curve y(x), but given the number of points in x it appears that the curve y(x) is dense in points. If y is monotonic, then it's straightforward.
xvals = interp1(y,x,Feyqlimit,'spline')
% or just
xvals = spline(y,x,Feyqlimit)
If y is not monotonic, then with this method you would split it up into monotonic subsections, each with its own accompanying range of x. Then in each subsection,
xvals = interp1(y,x,[F1, F2 ...],'spline')
% or just
xvals = spline(y,x,[F1, F2 ...])
where [F1, F2 ...] are the values of Feyqlimit that are possible in that subsection. (This could possibly give more than one value of x for some values of F, but from looking at the graph I assume that you know which x value would apply).
Generally the interpolated x value will not be a point in the x array, but if you do want such a point you can use interp1 with the 'nearest' option.
  댓글 수: 3
David Goodmanson
David Goodmanson 2020년 3월 11일
Hi Johnathan,
certainly by eye the data would fit better if the orange curve had parameters such that it ended up shifted to the left. I don't know how much control you have over that curve, or if it is totally set. That aside, the interp technique does not work very well if the fitting curve gets too horizontal. One approach is to cut the curve in two parts by deleting its values less than, say, DeltaFe56 < -1.5. For arrays Fo and DeltaFe56 (D56 for short), the following example divides each of the arrays into part a (red) and part b (yellow), which can be used separately.
% example curve
Fo = 80:.1:88;
D56 = .1*(Fo-84).^2 - 1.6;
N = length(Fo);
ind = find(D56<-1.5);
ind1 = min(ind); % max and min indices of the deleted part
ind2 = max(ind);
Foa = Fo(1:ind1-1);
D56a = D56(1:ind1-1);
Fob = Fo(ind2+1:N);
D56b = D56(ind2+1:N);
plot(Fo,D56,Foa,D56a,Fob,D56b)
grid on
Jonathan Pinko
Jonathan Pinko 2020년 3월 12일
Hi David,
Thank you for your answer.
Upon thinking about this problem a little more, I'm thinking that I might be asking the wrong questions, so I'm trying to go in a different direction that what this post was centered on.
Thanks again for your help though.
Jonathan

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

카테고리

Help CenterFile Exchange에서 Interpolation에 대해 자세히 알아보기

제품


릴리스

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by