-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPS3.m
More file actions
19 lines (15 loc) · 652 Bytes
/
PS3.m
File metadata and controls
19 lines (15 loc) · 652 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
function PS=PS3(eps_A,eps_B,eps_C,f_A,f_B,f_C)
% Define the function to solve
func = @(eps_eff) f_A * (eps_A - eps_eff) / (eps_A + 2*eps_eff) + ...
f_B * (eps_B - eps_eff) / (eps_B + 2*eps_eff) + ...
f_C * (eps_C - eps_eff) / (eps_C + 2*eps_eff);
% Make an initial guess for eps_eff
eps_eff_guess = (f_A * eps_A + f_B * eps_B + f_C * eps_C) / (f_A + f_B + f_C);
% Use fsolve to solve the equation
options = optimoptions('fsolve', 'Display', 'iter');
[PS] = fsolve(func, eps_eff_guess, options);
end
% Check if the solution converged
% if exitflag <= 0
% error('fsolve did not converge to a solution');
% end