問題が発生した場合、変数 x1 と x2 および 3 つの結果 y の一連のデータがあり、次の方程式でモデル化する必要があります。
y = a + b * log10(x1 - cosd(alpha - x2)) % I suppose that dcos = cosd, I do not really known this functions
まず、この値のデータを作成します。
function y = getting_data(x1,x2)
a = 3;
b = 5;
alpha = 120;
y = a + b * log10(x1 - cosd(alpha - x2));
それでは、データセットを生成しましょう
>> % generate the data sets
>> x1 = 9 .* rand(1000,1) + 1; % random values [1,10]
>> x2 = 360 .* rand(1000,1); % random values [0,360]
>> y = getting_data(x1,x2); % the values for the function
モデルにカーブ フィッティングを使用する関数を作成する
function myfit = fitting_data(x1,x2,y)
myfittype = fittype('a + b * log10(x1 - cosd(alpha - x2))',...
'dependent',{'y'},'independent',{'x1','x2'},...
'coefficients',{'a','b','alpha'})
myfit = fit([x1 x2],y,myfittype)
入力ベクトルに注意してください。フィット関数に対して nx1 である必要があります
最後に係数を取得します。
>> fitting_data(x1,x2,y)
myfittype =
General model:
myfittype(a,b,alpha,x1,x2) = a + b * log10(x1 - cosd(alpha - x2))
Warning: Start point not provided, choosing random start point.
> In curvefit.attention.Warning/throw (line 30)
In fit>iFit (line 299)
In fit (line 108)
In fitting_data (line 7)
General model:
myfit(x1,x2) = a + b * log10(x1 - cosd(alpha - x2))
Coefficients (with 95% confidence bounds):
a = 3 (3, 3)
b = 5 (5, 5)
alpha = 120 (120, 120)
General model:
ans(x1,x2) = a + b * log10(x1 - cosd(alpha - x2))
Coefficients (with 95% confidence bounds):
a = 3 (3, 3)
b = 5 (5, 5)
alpha = 120 (120, 120)
私たちが推測する値を表します
また、次のように de con(A - B) を分離すると便利です。

そしてそれも覚えておいてください
