Find the nonlinear equation

6 Ansichten (letzte 30 Tage)
Shaghayegh Shahhosseini
Shaghayegh Shahhosseini am 6 Dez. 2021
I have the x y z values and could plot the nonlinear graph like attached but do not know how to find its equation,
can anyone help?

Antworten (1)

Abolfazl Chaman Motlagh
Abolfazl Chaman Motlagh am 8 Dez. 2021
If you have a form of equations they should obey you should try fit that function on your data. you can use eather fit functions or optimization functions. if not your problem is kinda interpolation or again fitting but with a set of test functions.(like fourier or taylor expansion) (or like piece-wise interpolation methods).
As i can get from your plot, you are searching for a parametric Curve not a surface on 3 dimensional space. an equation like F(x,y,z)=0 yield to a surface. a parametric curve is like:
but by removing one of condition (if at least one of functions is invertible) you can find other 2 variables as funtions of third one. for example :
so the task is find and . a simple solution in matlab is using fit function. i give an example here:
alpha = 0:0.01:1;
X = cos(2*pi*alpha);
Y = sin(2*pi*alpha);
Z = 5*alpha;
plot3(X,Y,Z,'LineWidth',3);
figure;
subplot(1,2,1);plot(Z,X,'LineWidth',3);xlabel('Z');ylabel('X');
subplot(1,2,2);plot(Z,Y,"LineWidth",3);xlabel('Z');ylabel('Y');
so here we can use just Z as a parameter (cause the Z values are unique and it can use as a independent variable, in other word is invertible in all domain)
fitobject_1 = fit(Z',X','cubicinterp');
fitobject_2 = fit(Z',Y','cubicinterp');
figure;
subplot(1,2,1);plot(fitobject_1,Z,X);
subplot(1,2,2);plot(fitobject_2,Z,Y);
so you can use the function returns from fit as your solutions.
for evaluating a value use feval function on fit outputs.
X_=feval(fitobject_1,Z);
Y_=feval(fitobject_2,Z);
(because in this example of mine the plot is very accurate i shift the fitted curve a little in z direction to both become visible)
figure;plot3(X,Y,Z,'LineWidth',2);hold on;plot3(X_,Y_,Z+0.1,'LineWidth',2);legend('Data','Fitted')

Kategorien

Mehr zu Least Squares finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by