Trying to solve system of equations in a for loop. What is happening with my arguments?

1 回表示 (過去 30 日間)
Matt
Matt 2015 年 11 月 28 日
編集済み: Matt 2015 年 12 月 1 日
I am trying to solve eqs, which is a system of 3 equations and 3 unknowns, for multiple values of the parameter S.
function F=eqs(a)
F(1) = acos(((1-2*a(1))^2+(1-2*a(2))^2 )^(1/2)/(2*a(3)))+acos(a(1)/a(3))+...
acos(a(2)/a(3))+((1-2*a(1))^2+(1-2*a(2))^2 )^(1/2)/2*((a(3))^2-1/4*...
((1-2*a(1))^2+(1-2*a(2))^2 ))^(1/2)/((S-2*(a(3))^2 ) )+(a(1)*...
((a(3))^2-(a(1))^2 )^(1/2))/((S-2*(a(3))^2 ) )+(a(2)*((a(3))^2-(a(2))^2 )...
^(1/2))/((S-2*(a(3))^2 ) )-pi
F(2) = (4*a(2)*(a(3))^2+a(2)-4*(a(3))^2)/(4*a(2)-4*(a(3))^2-1)-a(1)
F(3) = (1-2*a(2))/((1-2*a(1))^2+(1-2*a(2))^2 )^(1/2) *((a(3))^2-1/4*...
((1-2*a(1))^2+(1-2*a(2))^2 ))^(1/2)-((a(3))^2-(a(2))^2 )^(1/2)
end
I need advice. My current version of trying to solve eqs 84 times is to call eqs into a second function eqs2
function g=eqs2(a)
d=[0.3 0.4 0.5];
for t=1:84
S=(t+16)/100
g(t)=fsolve(eqs,d)
end
end
The first thing MATLAB tells me is "Error using eqs (line 2) Not enough input arguments," which confuses me because eqs functions properly by itself.
I also may need help on letting eqs share the same set of S parameters as eqs 2 (global parameters? nested functions? I am new to all of it so any advice will help!).
Please help. (Thanks in advance!)

採用された回答

Walter Roberson
Walter Roberson 2015 年 11 月 28 日
g(t)=fsolve(@eqs,d)
  2 件のコメント
Matt
Matt 2015 年 11 月 30 日
編集済み: Matt 2015 年 12 月 1 日
Fair enough. What does the @ actually do in this case? Thanks for the help! Now all I have to do is figure out how to use the S in multiple functions.
Update: It turns out I had 10,000 other issues but this helped me to eliminate some of them. Thank you much!

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

その他の回答 (0 件)

カテゴリ

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