简体   繁体   English

使用Matlab进行2D拟合?

[英]2D fitting using matlab?

This may sound like an old question. 这听起来像是一个老问题。 I thought I know the code, but running it does not give me expected values. 我以为我知道代码,但是运行它并没有给我期望的值。

My problem is: 我的问题是:

target function: f = C / (x ^ p * y ^ q) 目标函数: f = C / (x ^ p * y ^ q)

(if you know something about machining, you can tell that this is the Taylor's tool life equation) (如果您对加工有所了解,则可以说这就是泰勒的刀具寿命方程式)

x and y are independent variables; xy是自变量; f is dependent variable; f是因变量; C , p and q are coefficients. Cpq是系数。

I have three sets of ([x, y], f) values as the following, please see "exp_result". 我有以下三组([x, y], f)值,请参阅“ exp_result”。

And I am looking for a best-fit surface for the three sets of values. 我正在为这三组值寻找最合适的表面。

Here's my code: 这是我的代码:

By running it I get: 通过运行它,我得到:

  • C 1.224E4
  • p 2.025
  • q 5.688

So the equation of my best-fit surface is T = 1.224E4 / (x ^ 2.025 * y ^ 5.688) . 因此,我最适合的表面的方程为T = 1.224E4 / (x ^ 2.025 * y ^ 5.688)

However, at least I found that this equation fits the three sets of data better: T = 9.83E7 / (x ^ 3.39 * y ^ 2.63) . 但是,至少我发现该方程式更适合三组数据: T = 9.83E7 / (x ^ 3.39 * y ^ 2.63)

By plugging in the x 's and y 's, I get far closer f 's using this equation. 通过插入xy ,可以使用该方程式更接近f Anyone has an idea where I did wrong? 有人知道我做错了吗?

Any suggestions are appreciated. 任何建议表示赞赏。 Thank you! 谢谢!

exp_result = [153.6   0.51  22.47; 192.01  0.61  6.52; 230.42  0.51  5.58];

f_exp = fittype('C / (x ^ p * y ^ q)', 'coefficients', {'C', 'p', 'q'}, 'independent', {'x', 'y'}, 'dependent', {'f'});

f_exp_coef = fit([exp_result(:,1), exp_result(:, 2)], exp_result(:, 3),f_exp);

The scale of C is very different from the other two parameters, making it harder to fit. C的标度与其他两个参数完全不同,因此更难拟合。

(1) either by giving a closer initial guess (1)通过给出更接近的初始猜测

or (2) rewrite the function in log term 或(2)以对数形式重写函数

log(f) = log(C) - p*log(x) - q*log(y) or f' = c - p*x' - q*y' log(f)= log(C)-p * log(x)-q * log(y)或f'= c-p * x'-q * y'

use [log(f) log(x) log(y)], you can obtain c, p, q which are in the same range [1 10], this hopefully give you a better fit. 使用[log(f)log(x)log(y)],可以获得c,p,q在相同范围内的值[1 10],这希望可以使您更适合。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM