I have xyz data from which i want to formulate an equation

50 次查看(过去 30 天)
hello everyone, so previously i had used this xyz data to make a 3D plot. However i now want to formulate an equation out of this data?
i want to solve for z inserting x and y
any idea how i could do that
this is the code i have used for the 3D plot
T1 = readtable('solarcol3.csv');
VarNames = T1.Properties.VariableNames;
x = T1{:,1};
y = T1{:,2};
z = T1{:,3};
[Ux,iax,ixx] = unique(x);
[Uy,iay,ixy] = unique(y);
N = 25;
xv = linspace(min(x), max(x), N);
yv = linspace(min(y), max(y), N);
[Xm,Ym] = ndgrid(xv, yv);
Zm = griddata(x, y, z, Xm, Ym, 'cubic'); % specify cubic interpolation
Zm = smoothn(Zm,1000); % Fex : https://fr.mathworks.com/matlabcentral/fileexchange/25634-smoothn?s_tid=ta_fx_results
Unrecognized function or variable 'smoothn'.

回答(1 个)

Walter Roberson
Walter Roberson 2023-5-26
No, it can be shown mathematically (and I have posted proofs before) that given any finite set of finitely-represented points, that there are an uncountable infinity of functions that mathematically pass exactly through all of those points.
Because there is an infinite number of potential equations to choose from, the probability that any one equation is the "right" equation is 1/infinity ... which is zero.
The best you can do is pre-determine a finite list of models that have no more parameters than the number of points you have, and do fitting to determine the best model parameters for each possibility, and then check to see which of the models had the "best" fit.
However, it is common to discover that if you do tests by generating points according to a known model and then add even a tiny amount of noise, that some other completely "wrong" model will fit the points better than the known right model form does. For example you might discover that where your actual model was polynomial degree 6 plus a small bit of noise, that a sum-of-exponentials fit better than polyfit(x,y,6)... because by accident there was a small bit of long-term correlation in the noise that was added.
  3 个评论
Walter Roberson
Walter Roberson 2023-5-26
Suppose you can show that over the range of your x values, -1 to +1, that the polynomial
x^17/355687428096000 + x^16/20922789888000 + x^15/1307674368000 + x^14/87178291200 + x^13/6227020800 + x^12/479001600 + x^11/39916800 + x^10/3628800 + x^9/362880 + x^8/40320 + x^7/5040 + x^6/720 + x^5/120 + x^4/24 + x^3/6 + x^2/2 + x + 1
fits you data perfectly to to within the (single) precision of your inputs.
So that would be it, right? The polynomial would be "the" equation, right?
Ah, but that polynomial is taylor(exp(x), x, 0, 'order', 17) -- so to within the error of your data exp(x) might be an equally valid solution. How to decide? Is the equation "really" the degree-17 polynomial, or is the equation "really" exp(x) ?
No system operating on finitely represented values can determine the difference.
Alex Sha
Alex Sha 2023-5-27
Walter gives a very good explanntion. One of functions looks like bellow:
z = (p1+p2*x+p3*y+p4*x*y)/(1+p5*x+p6*y+p7*x*y)+p8;
Sum Squared Error (SSE): 0.00885938009296813
Root of Mean Square Error (RMSE): 0.0156873800065957
Correlation Coef. (R): 0.992629641433234
R-Square: 0.985313605051871
Parameter Best Estimate
--------- -------------
p1 -0.428781064157635
p2 0.0594834002179455
p3 0.000475515732748892
p4 -4.72419933735348E-5
p5 -0.00466058481058043
p6 0.00305034598701402
p7 -0.0004153284867253
p8 0.43159235394028

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Polynomials 的更多信息

产品


版本

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by