Plotting the different solution via fzero solver against a range of one of the variable

1 Ansicht (letzte 30 Tage)
I am bit new to the matlab; I am having trouble with this, I got different values of phi0 at different Nt using fzero solver; called phi0value. I want to plot Nt v/s phi0value? I used plot (Nt, phi0) for this, it is not working. I dont know how to plot a range of output against a range of variable? Please guide me through this.This will be a great help!! Thank You.
N = 100;
% define the parameters
Nd = 1e23;
e = 12*1e-12;
%r = 0
R = 20*1e-9;
Et_Ef = -0.21*1.6*1e-19;
K = 1.3807e-23;
T = 600;
Nt = linspace(1e15,1e17,N);
q = 1.6e-19;
for i = 1:N
Ld = sqrt(e*K*T/(q^2*Nd))
funct= @(R,phi0) (4.*pi.*(Nd-Nd.*exp(-phi0)).*R.^2)
equation = @(phi0)integral(@(R)funct(R,phi0),0,R,'ArrayValued',true)-(4*pi.*R.^2.*Nt(i)./(1+2*exp((Et_Ef + K*T .*(phi0 + (1/6).*(R/Ld).^2))/(K.*T))));
%X= [0 10];
phi0value = fzero(equation,10)
end
plot (Nt,phi0val)

Akzeptierte Antwort

Stephan
Stephan am 7 Jun. 2019
N = 100;
% define the parameters
Nd = 1e23;
e = 12*1e-12;
%r = 0
R = 20*1e-9;
Et_Ef = -0.21*1.6*1e-19;
K = 1.3807e-23;
T = 600;
Nt = linspace(1e15,1e17,N);
q = 1.6e-19;
phi0value = zeros(1,N);
for ii = 1:N
Ld = sqrt(e*K*T/(q^2*Nd))
funct= @(R,phi0) (4.*pi.*(Nd-Nd.*exp(-phi0)).*R.^2)
equation = @(phi0)integral(@(R)funct(R,phi0),0,R,'ArrayValued',true)-(4*pi.*R.^2.*Nt(ii)./(1+2*exp((Et_Ef + K*T .*(phi0 + (1/6).*(R/Ld).^2))/(K.*T))));
%X= [0 10];
phi0value(ii) = fzero(equation,10)
end
plot (Nt,phi0value)
  1 Kommentar
Anil Kumar
Anil Kumar am 7 Jun. 2019
Thank you for your response! I had resolved this problem already! anyway thank you for your time. I have another issue. I want to integrate "funneff" and want to plot neff against Nt! Problem is that I am not able to integrate the function "funneff". Also how to plot neff v/s Nt ? below is my code. I am beginner in matlab. below is my code. Thanks in advance!
Nd = 1e24;
N = 100;
e = 12*1e-12;
% R = [10e-9,20e-9,30e-9,40e-9];
R = [1e-9,2e-9,3e-9,4e-9,5e-9,6e-9,7e-9,8e-9];
Et_Ef = -1.21*1.6*1e-19;
K = 1.3807e-23;
T = 600;
Nt = linspace(1e13,1e16,N);
q = 1.6e-19;
Ld = sqrt(e*K*T/(q^2*Nd));
for j = 1:numel(R)
for i= 1:N
funct = @(R,phi0) (4*pi*(Nd-Nd*exp(-phi0))*R.^2);
equation = @(phi0)integral(@(R)funct(R,phi0),0,R(j))-(4*pi*R(j)^2*Nt(i)/(1+2*exp((Et_Ef + K*T *(phi0 + (1/6)*(R(j)/Ld)^2))/(K*T))));
%equation = @(phi0)integral(@(r)funct(r,phi0),0,R)-(4*pi*R^2*Nt(i)/(1+2*exp((Et_Ef + K*T *(phi0 + (1/6)*(R/Ld)^2))/(K*T))));
phi0val(j,i) = fzero(equation,40);
%phi0val(i) = fzero(equation,40)
end
end
% plot(Nt,phi0val(1,:))
% hold on
% plot(Nt,phi0val(2,:))
% hold on
% plot(Nt,phi0val(3,:))
% hold on
% plot(Nt,phi0val(4,:))
% hold on
% plot(Nt,phi0val(5,:))
% hold on
% plot(Nt,phi0val(6,:))
% hold on
% plot(Nt,phi0val(7,:))
% hold on
% plot(Nt,phi0val(8,:))
for j = 1:numel(R)
for i=1:N
funneff= @(R)1./(4/3.*pi.*R(j).^3).*(Nd.*exp(-phi0val(j,i))).*R(j).^2
neff(j,i)= integral(funneff,0,R(j),'Arrayvalued',true)
end
end
plot(neff(1,:),phi0val(1,:))
hold on
plot(neff(2,:),phi0val(2,:))
hold on
plot(neff(3,:),phi0val(3,:))
hold on
plot(neff(4,:),phi0val(4,:))
hold on
plot(neff(5,:),phi0val(5,:))
hold on
plot(neff(6,:),phi0val(6,:))
hold on
plot(neff(7,:),phi0val(7,:))
hold on
plot(neff(8,:),phi0val(8,:))

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Community Treasure Hunt

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

Start Hunting!

Translated by