solving 4 equation with 4 unkowns
2 ビュー (過去 30 日間)
古いコメントを表示
good evening
i've been trying to solve these 4 equations using fsolve but the error Index exceeds array bounds. Kept appearing.
i've read multiple posts with the same problem but i couldn' solve the problem
is there anything wrong in the equations that i haven't noticed ?
thanks for the help
function F = myfun(x)
F = [
x(4) -135 +x(2);
130*cos(x(1)) - 31.7*cos(x(2)) - 140*cos(x(3)) - 146.4*cos(172.15);
130*sin(x(1)) - 31.7*sin(x(2)) - 140*sin(x(3)) - 146.4*sin(172.15);
-45*cos(x(4)) + 70*cos(x(5)) - 140*cos(x(3)) - 53.85*cos(68.198);
-45*sin(x(4)) + 70*sin(x(5)) - 140*sin(x(3)) - 53.85*sin(68.198);
];
end
2 件のコメント
Lubos Smolik
2020 年 4 月 6 日
Could you also provide your main script? It appears that there are 5 equations in your function.
回答 (1 件)
darova
2020 年 4 月 6 日
It's because of the way you concantenate your equations
Example of two different declarations
[1 - 2]
ans =
-1
[1 -2]
ans =
1 -2
Better practice would be:
F = zeros(5,1);
F(1) = x(4) -135 +x(2);
F(2) = 130*cos(x(1)) - 31.7*cos(x(2)) - 140*cos(x(3)) - 146.4*cos(172.15);
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Symbolic Math Toolbox についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!