フィルターのクリア

How can I dynamically create equations for fsolve?

4 ビュー (過去 30 日間)
lzeeysjp
lzeeysjp 2018 年 10 月 11 日
回答済み: Walter Roberson 2018 年 10 月 11 日
I need to solve a large system of non-linear equations (static truss system). The equations are derived from nodes (xyz), forces (xyz) and their constraints (position, forces).
How can I set-up equations like the following ones for fsolve dynamically?
F(1) = exp(-exp(-(x(1)+x(2)))) - x(2)*(1+x(1)^2);
F(2) = x(1)*cos(x(2)) + x(2)*sin(x(1)) - 0.5;
Or is there no good way to do this and it can only be handled by a symbolic solver like Mathematica? But even symbolic tools have to put the equations together somehow.
Does someone have an idea on how this works?
  2 件のコメント
KSSV
KSSV 2018 年 10 月 11 日
Run a loop.....and store the result into a cell array.
lzeeysjp
lzeeysjp 2018 年 10 月 11 日
But I don't have the equations. I need to create them somehow from the input. E.g. I need to look through all my input to see where Node1 is listed, e.g. by its position or by an equilibrium of forces with a neighbouring node. That for all nodes and forces.

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

回答 (1 件)

Walter Roberson
Walter Roberson 2018 年 10 月 11 日
If need be you can use str2func()
However I suspect that more appropriate would be to categorize into cases and call auxiliary construction functions passing in appropriate data with the construction functions returning anonymous functions that have captured appropriate data values. For example a cell array of function handles that you cellfun over, passing in x to each one, sum() the results.

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by