How to solve the two equations numerically in which tabular data is also to be loaded?
1 次查看(过去 30 天)
显示 更早的评论
I have two equations as;
(D-0.025)^1.5 * J(c) = 0.0025;
c = 0.5 - 0.01/D;
Where J(c) is the particular value of J corresponding to value of c.
There is table (c vs J) to be loaded in which values of "J" (2nd column) corresponding to "c" (1st column) are given as under
Table = [0.1 0.1156; 0.2 0.1590; 0.3 0.1892; 0.4 0.2117; 0.5 0.2288; 0.6 0.2416; 0.7 0.2505]
My problem: 1. I want to find optimal value of "D" and "J".
Also Note that its not important that the value of D exist in the table; so i also need to interpolate the value of "D"(existing in between two cells) and corresponding "J" value.
0 个评论
采纳的回答
Walter Roberson
2018-8-14
You can rewrite the interpolation as a polynomial of degree 6; it works out as
- (25*x^6)/12 + (145*x^5)/24 - (359*x^4)/48 + (499*x^3)/96 - (239*x^2)/100 + (10583*x)/12000 + 117/2500
You can then substitute that into your equations, converting all of your floating point values to rationals.
The system you get can then be solved in terms of a value that is the primary root of a degree 15 polynomial,
R = root([512 -15616 222208 -1962496 12118592 -56160800 203296128 -579497504 1277765482 -2115195465 2460287016 -1208021246 11455984710 -86217800113 215987875056 -180007884864])
D = (1/10)*(86016*R^14-2476544*R^13+32687360*R^12-257504256*R^11+1311552000*R^10-4612323392*R^9+12775515552*R^8-33673493056*R^7+86104656976*R^6-190723241666*R^5+393335706409*R^4+1248605641188*R^3-12283484659202*R^2+31089547519966*R-25920766050455)/(136192*R^14-3095552*R^13+19046656*R^12+161221632*R^11-3087622016*R^10+19694850944*R^9-63486597472*R^8+88752422720*R^7+101264091972*R^6-913631183772*R^5-936427888987*R^4+34659208386904*R^3-152565699173910*R^2+279861195719556*R-190086479566579)
c = (1/10)*(15616*R^14-444416*R^13+5887488*R^12-48474368*R^11+280804000*R^10-1219776768*R^9+4056482528*R^8-10222123856*R^7+19036759185*R^6-24602870160*R^5+13288233706*R^4-137471816520*R^3+1120831401469*R^2-3023830250784*R+2700118272960)/(3840*R^14-109312*R^13+1444352*R^12-11774976*R^11+66652256*R^10-280804000*R^9+914832576*R^8-2317990016*R^7+4472179187*R^6-6345586395*R^5+6150717540*R^4-2416042492*R^3+17183977065*R^2-86217800113*R+107993937528)
The values are approximately D = 0.07782594605604250, c = .3715081472598230
9 个评论
Walter Roberson
2018-8-15
N = size(T,1);
y = sym('y', [N, 1]);
interp_poly = poly2sym( polyfit(T(:,1), y, N-1), 'x' );
interp_poly would then be the same for each table that has the same T(:,1) values. However, it would have to be processed further to against the equations with solve() to get solutions.
更多回答(2 个)
Alan Weiss
2018-8-13
First you have to make a function that interpolates your data so that the function can be evaluated at any point. Load the c and J values into your workspace, then define
fun = @(xq)interp1(c,J,xq)
I didn't completely understand whether you have two functions that need to be interpolated or not; if so, then make a second function fun2 that interpolates your other function (D?). Now you can use standard equation-solving functions such as fzero or fsolve (from Optimization Toolbox™) to solve your equation or equations.
It is possible that you would want to use a smooth interpolation method in interp1. If so, see the interp1 function reference page.
Good luck,
Alan Weiss
MATLAB mathematical toolbox documentation
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!