How to find the complex root for this equations
1 view (last 30 days)
Show older comments
Ammar Ahmed
on 10 Jun 2019
Commented: Alex Mcaulley
on 11 Jun 2019
Hi guys!
I'M new using Matlab .
i'm trying to finding the roots for an effective permittivity equation in two form Quadratic and Nonlinear and it Should have the Same solution
any suggestion how to solve equations and find roots.
%Quadratic Equation
function ere= roots
p=[0.23,0.25,0.27]; % concentration of sample
er1=(1+1.8*10^14*i); % Phase one Permittivity
er2=(2.5+2.5*10^-3*i); % Phase two Permittivity
ere=(1./4).*(((3.*p-1).*er1)+((2-3.*p).*er2)+((((3.*p-1).*er1)+((2-3.*p).*er2)).^2+8.*er1.*er2).^0.5);
% effective permittivity
plot(p,ere)
end
Nonlinear Equation
function fval=eqns(ere)
P=[0.23,0.25,0.27];
er1=(1+1.8*10^14*1i);
er2=(2.5+2.5*10^-3*1i);
fval=((P).*((ere-er1)./(er1-2.*ere)))+((1-P).*((ere-er2)./(er2-2.*ere)));
plot(p,ere)
end
0 Comments
Accepted Answer
Alex Mcaulley
on 10 Jun 2019
First, one important suggestion: Don't call your function as one Matlab function (roots, in fact is the one that you need to call).
After that, the equation (3) is trivial, you get the value of ere directly as you have in your function:
p = [0.23,0.25,0.27]'; % concentration of sample
er1 = (1+1.8*10^14*i); % Phase one Permittivity
er2 = (2.5+2.5*10^-3*i); % Phase two Permittivity
ereEQ3 = (1./4)*(((3*p-1)*er1) + ((2-3*p)*er2) + ((((3.*p-1)*er1) + ((2-3*p)*er2)).^2+8*er1*er2).^0.5);
For the other equation (2), yo need to obtain the roots of the second orden polynomial. One option is to use the roots function. (Note that you will obtain 2 solutions for each value of p, and only one is the same than the one obtained with the previous equation).
pol = [2+p*0, (-2+3*p)*er2 + (1-3*p)*er1, -er1*er2+p*0];
ereEQ2 = arrayfun(@(i) roots(pol(i,:)),1:numel(p),'uni',0);
2 Comments
Alex Mcaulley
on 11 Jun 2019
It seems that you still have your function called roots. Change the name of your function, run this command in the command window:
clear all
And try to execute my code
More Answers (1)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!