Trying to solve system of equations in a for loop. What is happening with my arguments?
Show older comments
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!)
Accepted Answer
More Answers (0)
Categories
Find more on Numeric Solvers in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!