How to find the complex root for this equations
5 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
Alex Mcaulley
2019-6-10
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 个评论
Alex Mcaulley
2019-6-11
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
更多回答(1 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Particle & Nuclear Physics 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!