Back-Calculating to Match Previously Established Variable
4 次查看(过去 30 天)
显示 更早的评论
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.
0 个评论
回答(1 个)
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
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
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Interpolation 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!