简体   繁体   中英

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)

(if you know something about machining, you can tell that this is the Taylor's tool life equation)

x and y are independent variables; f is dependent variable; C , p and q are coefficients.

I have three sets of ([x, y], f) values as the following, please see "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) .

However, at least I found that this equation fits the three sets of data better: 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. 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.

(1) either by giving a closer initial guess

or (2) rewrite the function in log term

log(f) = log(C) - p*log(x) - q*log(y) or 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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