How to find the complex root for this equations

조회 수: 4 (최근 30일)
Ammar Ahmed
Ammar Ahmed 2019년 6월 10일
댓글: Alex Mcaulley 2019년 6월 11일
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

채택된 답변

Alex Mcaulley
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
Ammar Ahmed
Ammar Ahmed 2019년 6월 10일
hanks for replying i tried to use your command
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);
but it give me Error
Error using roots
Too many input arguments.
Error in @(i)roots(pol(i,:))
Alex Mcaulley
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개)

Ammar Ahmed
Ammar Ahmed 2019년 6월 10일
thanks for replying i tried to use your command
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);
but it give me Error
Error using roots
Too many input arguments.
Error in @(i)roots(pol(i,:))

카테고리

Help CenterFile Exchange에서 Numerical Integration and Differential Equations에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by