フィルターのクリア

How do I get a symbolic differentiation of cfit/sfit functions?

14 ビュー (過去 30 日間)
Tim Baur
Tim Baur 2019 年 12 月 12 日
コメント済み: Tim Baur 2020 年 1 月 2 日
Hi everyone,
I am trying to get the symbolic partial derivative of a sfit function. Best case would be having the differentition as an sfit function, too.
Thanks in advance!
EDIT:
Here's an example:
%data
x = [0.5850;0.0734;0.8223;0.7229;0.9259;0.4926];
y = [0.6549;0.8901;0.5385;0.2822;0.9760;0.0364];
z = [0.3262;0.9730;0.3650;0.3091;0.1209;0.9158];
%surface fit
sf = fit([x, y],z,'poly22')
plot(sf)
% Linear model Poly22:
% sf(x,y) = p00 + p10*x + p01*y + p20*x^2 + p11*x*y + p02*y^2
% Coefficients:
% p00 = 5.048
% p10 = -11.04
% p01 = -1.326
% p20 = 5.179
% p11 = 5.682
% p02 = -3.135
Now I could use the differentiate method to get the derivative at specific points but I would like to have the derived function, like this (witthout having to derive it manually):
% sf_x(x,y) = p10 + 2*p20*x + p11*y
  3 件のコメント
Tim Baur
Tim Baur 2019 年 12 月 13 日
Yes, I did. diff does not take sfit as input argument, unfortunately.
darova
darova 2019 年 12 月 13 日
Can you provide an example please?

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

採用された回答

Walter Roberson
Walter Roberson 2019 年 12 月 16 日
When sf is the fit object,
f = subs(str2sym(formula(sf)),coeffnames(sf),num2cell(coeffvalues(sf).'));
vars = sym(indepnames(sf));
diff(f, vars(1))
  5 件のコメント
Walter Roberson
Walter Roberson 2019 年 12 月 20 日
The upper and lower bounds are in the fit options, which I have it add in via 'options', fitoptions(sf)
Tim Baur
Tim Baur 2020 年 1 月 2 日
Thanks! :)

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeFit Postprocessing についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by