フィルターのクリア

fminsearch vector of results

1 回表示 (過去 30 日間)
MARCO FORTI
MARCO FORTI 2021 年 4 月 7 日
コメント済み: MARCO FORTI 2021 年 4 月 8 日
Here's my model:
Given the model, my intention is to estimate γ having the values of C, and .
I tryed with the following code, but the program returns me only one value for γ while I need the vector containing every value produced in the loop.
How can I fix the code to get it?
j=1; %increment level. The loop will work for j>1 as well.
for i=1:j:steps;
fnc = @(gamma,C,Sum_I) C(i)./(1+gamma) - (gamma./(1+gamma)).*Sum_I(i); % Model function
rn = @(gamma) norm(I - fnc(gamma,C,Sum_I)); % Residual norm
gamma0 = [15]; % Inizializzazione
[gamma, ResNorm] = fminsearch(rn, gamma0);
end

採用された回答

Walter Roberson
Walter Roberson 2021 年 4 月 7 日
steps = 5;
C = @cos;
Sum_I = @atan;
I = 42;
j=1; %increment level. The loop will work for j>1 as well.
for i=1:j:steps;
fnc = @(gamma,C,Sum_I) C(i)./(1+gamma) - (gamma./(1+gamma)).*Sum_I(i); % Model function
rn = @(gamma) norm(I - fnc(gamma,C,Sum_I)); % Residual norm
gamma0 = [15]; % Inizializzazione
[gamma(i), ResNorm(i)] = fminsearch(rn, gamma0);
end
gamma
gamma = 1×5
-0.9690 -0.9840 -0.9940 -0.9845 -0.9618
  1 件のコメント
MARCO FORTI
MARCO FORTI 2021 年 4 月 8 日
Thanks

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeGamma Functions についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by