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

1 vue (au cours des 30 derniers jours)
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!)

Réponse acceptée

Walter Roberson
Walter Roberson le 28 Nov 2015
g(t)=fsolve(@eqs,d)
  2 commentaires
Matt
Matt le 30 Nov 2015
Modifié(e) : Matt le 1 Déc 2015
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!

Connectez-vous pour commenter.

Plus de réponses (0)

Community Treasure Hunt

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

Start Hunting!

Translated by