필터 지우기
필터 지우기

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

조회 수: 1 (최근 30일)
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 CenterFile Exchange에서 Numeric Solvers에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by