fsolveの目的関​数を配列で出力する場​合の,要素ごとの計算​方法を教えてください​.

16 visualizzazioni (ultimi 30 giorni)
温大
温大 il 27 Ago 2024
Commentato: 温大 il 28 Ago 2024
関数fsolveを使用して,以下の非線形連立方程式を解きたいです.
G = [10 11 ; 12 13];
H = [-2 -1 ; -2 -3];
f = @(x)[x(1).*x(2)-5*x(2)+G(:,:), x(1).^3-x(2).^2+H(:,:)];
% 初期値
x0 = [I J];
I = [1 1 ; 1 1];
J = [1 1 ; 1 1];
x = fsolve(f,x0,options)
で,関数fの要素ごと(この例では2×2)で出力(x1,x2)を各要素で求めたいのですが,方法がわかりません.
分かる方いらっしゃいましたらご回答お願いいたします.

Risposta accettata

Atsushi Ueno
Atsushi Ueno il 27 Ago 2024
こういう事ではないかと思います。
G = [10 11 ; 12 13];
H = [-2 -1 ; -2 -3];
% f = @(x)[x(1) .*x(2) -5*x(2) +G(:,:), x(1) .^3-x(2) .^2+H(:,:)];
f = @(x)[x(:,1:2).*x(:,3:4)-5*x(:,3:4)+G(:,:), x(:,1:2).^3-x(:,3:4).^2+H(:,:)];
I = [1 1 ; 1 1];
J = [1 1 ; 1 1];
x0 = [I J]; % 初期値
x = fsolve(f,x0) % ,options)
Solver stopped prematurely. fsolve stopped because it exceeded the function evaluation limit, options.MaxFunctionEvaluations = 8.000000e+02.
x = 2x4
2.5303 2.7081 3.7861 4.3661 3.0843 3.1022 5.2623 5.2373
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
  1 Commento
温大
温大 il 28 Ago 2024
ありがとうございます.
提案していただいた解法でやりたいことが実現できました.

Accedi per commentare.

Più risposte (0)

Tag

Prodotti


Release

R2024a

Community Treasure Hunt

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

Start Hunting!