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

1 visualizzazione (ultimi 30 giorni)
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!)

Risposta accettata

Walter Roberson
Walter Roberson il 28 Nov 2015
g(t)=fsolve(@eqs,d)
  2 Commenti
Matt
Matt il 30 Nov 2015
Modificato: Matt il 1 Dic 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!

Accedi per commentare.

Più risposte (0)

Community Treasure Hunt

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

Start Hunting!

Translated by