フィルターのクリア

solving equations initially written as strings using fsolve

2 ビュー (過去 30 日間)
S H
S H 2019 年 4 月 29 日
コメント済み: Matt J 2019 年 4 月 29 日
Is it possible to solve the following equations that are initially written as string expressions?
eqns={...
'x(1)+x(2)+x(3)+x(4)+x(5)+x(6)+x(7)-1';...
'x(1)-a*x(2)';...
'x(2)-a*x(3)';...
'x(3)-a*x(4)';...
'x(4)-a*x(5)';...
'x(5)-a*x(6)';...
'x(6)-a*x(7)'};
for kk=1:7
myF{kk}=str2func(eqns{kk});
end
funeqns=@(x) myF{:};
a=2;
x0=0.5*ones(1,7);
opts=optimoptions('fsolve','Algorithm','trust-region','TolFun',1e-12,...
'TolX',1e-12,'Display','off');
fs=fsolve(funeqns,x0,opts)';
  9 件のコメント
S H
S H 2019 年 4 月 29 日
Exactly.
Matt J
Matt J 2019 年 4 月 29 日
So solve() should work fine.

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

回答 (0 件)

カテゴリ

Help Center および File ExchangeNumeric Types についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by