我如何使用 fittype 函数来定义自定义方程式?
How can i use fittype function to define a custom equation?
如何使用 fittype 函数定义以下自定义方程?
y = a(x1^b)(x2^c)(x3^d)(x4^e)(x5^f)(x6^g).
我尝试了以下代码:
ft = fittype( 'a*(x1^b)*(x2^c)*(x3^d)*(x4^e)*(x5^f)*(x6^g)',...
'independent',{'x1','x2','x3','x4','x5','x6'},...
'dependent',{'y'},...
'coefficients',{'a','b','c','d','e','f','g'});
但是它抛出这个错误:
Expression a*(x1^b)(x2^c)(x3^d)(x4^e)(x5^f)*(x6^g) is not a valid MATLAB expression, has non-scalar coefficients, or cannot be evaluated: Not enough inputs to FITTYPE function.
首先,'a*(x1^b)(x2^c)(x3^d)(x4^e)(x5^f)(x6^g)' 不是有效的 MATLAB 表达式。您应该将其更改为 'a(x1.^b).(x2.^c).(x3.^d).(x4.^e).(x5.^f).*(x6.^g)'。
其次,matlab处理不了那么多未知参数,短一个也行,像这样:
ft = fittype(@(a,b,c,x1,x2) a*(x1.^b).*(x2.^c),
'independent',{'x1','x2'},'dependent',{'y'},'problem',{'b','c'});
如何使用 fittype 函数定义以下自定义方程?
y = a(x1^b)(x2^c)(x3^d)(x4^e)(x5^f)(x6^g).
我尝试了以下代码:
ft = fittype( 'a*(x1^b)*(x2^c)*(x3^d)*(x4^e)*(x5^f)*(x6^g)',...
'independent',{'x1','x2','x3','x4','x5','x6'},...
'dependent',{'y'},...
'coefficients',{'a','b','c','d','e','f','g'});
但是它抛出这个错误:
Expression a*(x1^b)(x2^c)(x3^d)(x4^e)(x5^f)*(x6^g) is not a valid MATLAB expression, has non-scalar coefficients, or cannot be evaluated: Not enough inputs to FITTYPE function.
首先,'a*(x1^b)(x2^c)(x3^d)(x4^e)(x5^f)(x6^g)' 不是有效的 MATLAB 表达式。您应该将其更改为 'a(x1.^b).(x2.^c).(x3.^d).(x4.^e).(x5.^f).*(x6.^g)'。 其次,matlab处理不了那么多未知参数,短一个也行,像这样:
ft = fittype(@(a,b,c,x1,x2) a*(x1.^b).*(x2.^c), 'independent',{'x1','x2'},'dependent',{'y'},'problem',{'b','c'});