Generalized equation using multiple equation

x = [0.25 0.50 0.75 1 1.25 1.50 1.75 2 2.25 2..50 2.75 3]
y1 = [0.001524 0.00605 0.013592 0.024151 0.037728 0.054321 0.073921 0.096514 0.122102 0.150689 0.182278 0.21687]
y2 = [0.060598 0.14902 0.28793 0.42474 0.57648 0.78663 1.0389 1.6032 2.3667 3.1328 3.8971 4.6297]
y3 = [0.016373 0.0503 0.1896 0.60113 1.2101 1.8134 2.9318 4.0203 4.8728 6.1467 8.1357 10.277]
y4 = [0.11668 0.33853 0.66617 1.2037 1.6292 2.4379 3.6119 4.8274 6.0769 6.4846 8.064 9.6733]
y5 = [0.131518 0.418614 0.793038 1.33235 1.94051 2.54087 4.31947 5.25463 6.33347 7.82779 9.91558 12.4864]
Could someone provide guidance on how to derive a single equation that applies to all five curves, each of which includes a dimensionless parameter "z"? The goal is to have a generalized equation that can be used to obtain the corresponding values for all five cases by simply plugging in different values of "z" (e.g., 0, 0.5, 1, 2, and 2.5).
[Hint: When Z = 0 I will get black curve; When Z = 0.5 I will get blue curve; When Z = 1 I will get red curve; When Z = 2 I will get green curve; When Z = 2.5 I will get magenta curve] (I have also attached an image which also contains separate equations for all five curves in it)

 採用された回答

Matt J
Matt J 2023 年 5 月 1 日
編集済み: Matt J 2023 年 5 月 1 日

0 投票

You can use lsqcurvefit with model function,
xdata = [0.25 0.50 0.75 1 1.25 1.50 1.75 2 2.25 2.50 2.75 3];
y1 = [0.001524 0.00605 0.013592 0.024151 0.037728 0.054321 0.073921 0.096514 0.122102 0.150689 0.182278 0.21687];
y2 = [0.060598 0.14902 0.28793 0.42474 0.57648 0.78663 1.0389 1.6032 2.3667 3.1328 3.8971 4.6297];
y3 = [0.016373 0.0503 0.1896 0.60113 1.2101 1.8134 2.9318 4.0203 4.8728 6.1467 8.1357 10.277] ;
y4 = [0.11668 0.33853 0.66617 1.2037 1.6292 2.4379 3.6119 4.8274 6.0769 6.4846 8.064 9.6733] ;
y5 = [0.131518 0.418614 0.793038 1.33235 1.94051 2.54087 4.31947 5.25463 6.33347 7.82779 9.91558 12.4864];
ydata=[y1;y2;y3;y4;y5];
[x,fval]=lsqcurvefit(@F,ones(5,2),xdata,ydata,zeros(5,2))
Local minimum possible. lsqcurvefit stopped because the final change in the sum of squares relative to its initial value is less than the value of the function tolerance.
x = 5×2
0.0126 0.9669 0.1703 1.1217 0.3560 1.1323 0.6457 0.9198 0.6158 1.0116
fval = 8.4752
plot(xdata,ydata','x',xdata,F(x,xdata))
function out=F(x,xdata)
out=x(:,1).*exp( x(:,2).*xdata);
end

15 件のコメント

Torsten
Torsten 2023 年 5 月 1 日
Could someone provide guidance on how to derive a single equation that applies to all five curves, each of which includes a dimensionless parameter "z"? The goal is to have a generalized equation that can be used to obtain the corresponding values for all five cases by simply plugging in different values of "z" (e.g., 0, 0.5, 1, 2, and 2.5).
... your function has 2 fitting parameters.
Raj Arora
Raj Arora 2023 年 5 月 1 日
Thanks Matt. But can you tell me how can I get the generalized equation in terms of dimensionless parameter z using which I can get all 5 curves
[Hint: When Z = 0 I will get black curve; When Z = 0.5 I will get blue curve; When Z = 1 I will get red curve; When Z = 2 I will get green curve; When Z = 2.5 I will get magenta curve] (I have also attached an image which also contains separate equations for all five curves in it)
Matt J
Matt J 2023 年 5 月 1 日
編集済み: Matt J 2023 年 5 月 1 日
The equations are not separate in your attached figure. They are all functions of the same parameter v and there is no parameter Z anywhere.
Torsten
Torsten 2023 年 5 月 1 日
編集済み: Torsten 2023 年 5 月 1 日
From the physics of your problem: Should all the curves pass through a common point at xdata = 0 ?
Raj Arora
Raj Arora 2023 年 5 月 1 日
編集済み: Torsten 2023 年 5 月 1 日
Yeah. It should be in this format Y = F{x, z}
Raj Arora
Raj Arora 2023 年 5 月 1 日
@Matt J the equations are separate and they all are parameter of v but also they are for different z (dimensionless parameter)
@Torsten all curve should start from x = 0
Torsten
Torsten 2023 年 5 月 1 日
編集済み: Torsten 2023 年 5 月 1 日
Then try fitting with
f(x,z) = exp(z*x) - 1
or
f(x,z) = z*(exp(x)-1)
or
f(x,z) = x^(z)
or
f(x,z) = z*x^2
and see what comes out better.
Raj Arora
Raj Arora 2023 年 5 月 1 日
@Torsten I tried it like if T1, T2, T3, T4, T5 are 5 equation for all 5 cases then generalized equation will be
y = c1.T1.(z^1/4)+c2.T2.(z^1/5)+c3.T3.(z^1/6)+c4.T4.(z^1/7)+c5.T5.(z^1/8)
but using this I am getting the same patternn but I am not able to specify exact value of c1, c2, c3, c4 & c5
What are your thoughts about this?
Torsten
Torsten 2023 年 5 月 1 日
編集済み: Torsten 2023 年 5 月 1 日
I mean that you should try to fit each curve separately with one of the specified function using z as fitting parameter. If this gives an acceptable fit for each curve, you have determined your function f(x,z) that would work.
Matt J
Matt J 2023 年 5 月 1 日
編集済み: Matt J 2023 年 5 月 1 日
the equations are separate and they all are parameter of v but also they are for different z
@Raj Arora, but you do not show us the dependence on z in your equations. We do not know what model F(v,z) we are fitting.
Raj Arora
Raj Arora 2023 年 5 月 1 日
Yes Matt I didn't mentioned the dependence of z in my equations because that is a Dimensionless parameter. And for each curve (red blue black green magenta) all the data points (12) have the same value of z.
Matt J
Matt J 2023 年 5 月 1 日
編集済み: Matt J 2023 年 5 月 1 日
because that is a Dimensionless parameter
We don't know what you mean by that, or why it implies that it's role in the equations is negligible. You have data that is a function of 2 parameters, v and z. We need to know how the data is supposed to depend on both of these, not just v.
Raj Arora
Raj Arora 2023 年 5 月 2 日
By dimensionless I mean that equation is not dependent on z. But still I want to include this z in generalized equation and I dont have any relation of z with v and x.
Matt J
Matt J 2023 年 5 月 2 日
編集済み: Matt J 2023 年 5 月 2 日
I dont have any relation of z with v and x.
If not, your problem is under-specified. There are infinitely many possible surfaces F(v,z) that coincide with your plots at the prescribed z.
Raj Arora
Raj Arora 2023 年 5 月 2 日
Okay Matt J thankyou for your valuable comments. I will try something then I know a way that is multiple non linear regression
I tried it like if T1, T2, T3, T4, T5 are 5 equation for all 5 cases then generalized equation will be
y = c1.T1.(z^1/4)+c2.T2.(z^1/5)+c3.T3.(z^1/6)+c4.T4.(z^1/7)+c5.T5.(z^1/8)
Through this I am getting approriate fit but not the exact result for that I have to put correct value of c1, c2 , c3, c4 and c5

サインインしてコメントする。

その他の回答 (1 件)

Matt J
Matt J 2023 年 5 月 2 日
編集済み: Matt J 2023 年 5 月 2 日

0 投票

[Hint: When Z = 0 I will get black curve; When Z = 0.5 I will get blue curve; When Z = 1 I will get red curve; When Z = 2 I will get green curve; When Z = 2.5 I will get magenta curve] (I have also attached an image which also contains separate equations for all five curves in it)
Here is one choice which fulfills this, but as I mentioned earlier, it is only one choice of infinitely many:
z=[0,0.5,1,2,2.5];
a=[0.051512, 0.32887, 0.67073, 1.1425, 1.1132];
b=[0.96062, 1.1142,1.1155,0.91651,0.99419];
pa=polyfit(z,a,4);
pb=polyfit(z,b,4);
f=@(z,v) polyval(pa,z).*exp(polyval(pb,z).*v); %joint function of z and v
%Visual check
for z0=[0,0.5,1,2,2.5]
fplot(@(v)f(z0,v)); hold on
end
hold off, xlim([0,3])

カテゴリ

ヘルプ センター および File ExchangeGet Started with Curve Fitting Toolbox についてさらに検索

タグ

質問済み:

2023 年 5 月 1 日

編集済み:

2023 年 5 月 2 日

Community Treasure Hunt

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

Start Hunting!

Translated by