i want to solve a 10 equation, 10 states with fsolve , but it does not give me the answer.
1 回表示 (過去 30 日間)
古いコメントを表示
HI Guys. Actually I want t o test that is there a 4x4 matrix named P which is positive and A1'*P+P1*A1 and also A2'*P+P1*A2 are negative matrixes?
May you please guide me how can I test/ do that?
Firstly I try to solve a 2x2 matrix P with Fsolve in a way that A1'*P+P*A1=-eye(2,2) , and see is there any positive p that gives me this result, but actually the bellow code that I wrote does not give me any solution. Why?
And I will be thankful if any one can help me in my problem in 4x4 matrix A1,A2 that I write in my mfile.
clear all;
clc;
close all;
A1=[3.4*10^-15 7.6*10^-6;1 4];
%A1=[3.4*10^-15 7.6*10^-6 0 0;-4*10^-16 -6.5*10^-5 0 0;2.3*10^-16 0.00059 -0.1426 0;-8.159*10^-14 -0.05 18.21 0.08];
A2=[9.04*10^-7 -1.48*10^-6 0 0;-1.977*10^-7 -1.008*10^-5 0 0;9.24*10^-8 0.00045 -0.127 0;-8.55*10^-5 -0.10 65.217 -0.0833];
syms p1
syms p2
syms p3
syms p4
syms p5
syms p6
syms p7
syms p8
syms p9
syms p10
%P=[p1 p2 p3 p4;p2 p5 p6 p7;p3 p6 p8 p9;p4 p7 p9 p10];
P=[p(1) p(2);p(2) p(3)];
p(1)>0;
det(P)>0;
function F = myfun(p)
F=A1'*P+P*A1+eye(2,2)=0;
p0=[1 1;1 1];
[p,fval]=solve(@myfun,p0)
4 件のコメント
Walter Roberson
2019 年 4 月 12 日
azam ghamari comments to John D'Errico
Ok, I want to solve firstly this problem (fsolve) and then my initial question. Thanks
採用された回答
azam ghamari
2019 年 4 月 12 日
1 件のコメント
John D'Errico
2019 年 4 月 12 日
Please learn to use comments instead of adding multiple answers just ot make a response.
その他の回答 (2 件)
Walter Roberson
2019 年 4 月 12 日
A1=[3.4*10^-15 7.6*10^-6;1 4];
%A1=[3.4*10^-15 7.6*10^-6 0 0;-4*10^-16 -6.5*10^-5 0 0;2.3*10^-16 0.00059 -0.1426 0;-8.159*10^-14 -0.05 18.21 0.08];
A2=[9.04*10^-7 -1.48*10^-6 0 0;-1.977*10^-7 -1.008*10^-5 0 0;9.24*10^-8 0.00045 -0.127 0;-8.55*10^-5 -0.10 65.217 -0.0833];
P = sym('p', [1 3]);
sol = solve(myfun(P,A1));
p = vpa([sol.p1, sol.p2, sol.p3]);
disp(p)
function F = myfun(p, A1)
P=[p(1) p(2);p(2) p(3)];
F=A1'*P+P*A1+eye(2,2);
end
17 件のコメント
Walter Roberson
2019 年 4 月 17 日
When you did the fsolve(), you overwrote the P variable that I had created by
P = sym('p', [1 3]);
Use a different output variable for fsolve(), or at least postpone the fsolve() until after the solve()
Note: those lines with sym p(1) and so on are wrong and will cause an error. You will also find that sol.p does not have 3 entries.
I do not know why you insist on breaking the working code that I give you.
azam ghamari
2019 年 4 月 17 日
2 件のコメント
Walter Roberson
2019 年 4 月 17 日
https://www.mathworks.com/matlabcentral/answers/455900-i-want-to-solve-a-10-equation-10-states-with-fsolve-but-it-does-not-give-me-the-answer#comment_693628 and notice I refer to sol.p1 not sol.p(1)
参考
カテゴリ
Help Center および File Exchange で Assumptions についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!