Non linear equation containing integral

I am bit new with matlab programming. I want to solve the above equation for phi0 but getting problem using solve function. Please help me. I expect a solution like this: different phi0 for different Ntpicture 1.png
clc;clear;close all;
warning('off')
% number of data points for r, R and Et-Ef
N = 100;
% define the parameters
Nd = 1e24;
e = 12*1e-12;
r = 40*1e-9
R = 40*1e-9;
Et_Ef = 0.21*1.6*1e-19;
K = 1.3807e-23;
T = 600;
Nt = 1e11;
q = 1.6e-19;
for j = 1:length(Nt)
% initializing
LHS_vals = [];
RHS_vals = [];
P = [];
% loop to solve LHS - RHS = 0 N times
for i = 1:N
syms phi0
Ld = sqrt(e*K*T/(q^2*Nd));
integrand = @(r)Nd-(Nd.*exp(-1.*(phi0+(1./6).*(r(i)/Ld).^2)));
LHS = integral (integrand,0,40*10^-9);
RHS = 4.*pi.*R.^2.*Nt./(1+2.*exp(Et_Ef + K.*T .*(phi0 + (1/6).*(r(i)./Ld).^2)));
eq = LHS - RHS==0;
phi0 = solve(eq,phi0)
if ~isempty(phi0)
LHS_vals(end+1) = eval(LHS);
RHS_vals(end+1) = eval(RHS);
P(end+1) = phi0;
fprintf('LHS - RHS = %1.2e\n',eval(LHS) - eval(RHS))
end
end
%Plotting the Figure
if ~isempty(P)
figure()
hold on
plot(P,RHS_vals,'r--')
plot(P,LHS_vals,'b--')
hold off
xlabel('\phi_0')
ylabel('LHS,RHS')
ax = gca;
ax.YScale = 'log';
legend('RHS','LHS')
end
end
%plot (r,phi0)

댓글 수: 5

Matt J
Matt J 2019년 6월 3일
Do the values you are getting solve the equations?
Anil Kumar
Anil Kumar 2019년 6월 3일
No Sir, After execution of this code; i am getting error:
Error using integralCalc/finalInputChecks (line 522)
Input function must return 'double' or 'single' values. Found 'sym'.
Error in integralCalc/iterateScalarValued (line 315)
finalInputChecks(x,fx);
Error in integralCalc/vadapt (line 132)
[q,errbnd] = iterateScalarValued(u,tinterval,pathlen);
Error in integralCalc (line 75)
[q,errbnd] = vadapt(@AtoBInvTransform,interval);
Error in integral (line 88)
Q = integralCalc(fun,a,b,opstruct);
Error in final03062019 (line 30)
LHS = integral(integrand,0,40*10^-9);
Anil Kumar
Anil Kumar 2019년 6월 3일
I want to know whether it is the right approach for the solution? phi0 value will be given by the intersection of LHS solution and RHS solution for a particular value of Nt!
Anil Kumar
Anil Kumar 2019년 6월 3일
It has been a long time I am stuck in this problem! Please help me.
SACHIN VERMA
SACHIN VERMA 2020년 5월 29일
sir, i also got stuck in simlar problem, please help if anyone knows how to solve it for complicated functions like above...

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

도움말 센터File Exchange에서 Mathematics에 대해 자세히 알아보기

질문:

2019년 6월 3일

댓글:

2020년 5월 29일

Community Treasure Hunt

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

Start Hunting!

Translated by