MATLAB: Im trying to plot this on a log log scale, with T=1000, and R = [1e-10:1e-11:1e-9]. when i get the numerical answers it works, but no lines appear when i try and plot it.

help pleaseits probably something obvious

function [dnondt] = DGm(R,T)
rhol = 3000;
m1 = 2.49e-25;
p = 2e5;
L = 798366.2;
cbg = 2057.97;
v1 = m1/rhol;
kb = 1.3807e-23;
mg = 2.989e-26;
mc = 2.49e-25;
K=0.0976;
s = 1.1;
cgbar = (((8*kb*T)/(pi*mg)))^(1/2);
Ps = exp(22.111-((m1*L)/(kb))/T);
ng = ((p)/(kb*T));
heat = ((m1^2*L^2)/(kb^2*T^2))*(((kb*R)/(K))+((4*kb)/(cbg*cgbar*ng*mg)));
nms = (Ps)/(kb*T);
cnbar = (((8*kb*T)/(pi*mc)))^(1/2);
D = 7.249e-5*((T^1.75)/(p));
mass =((4)/(nms*cnbar))*((1)+((R*cnbar)/(4*D)));
dnondt = 4*pi*R.^2*(s-1)/(heat+mass);
end

Best Answer

You have to vectorise every calculation involving the ‘R’ vector, especially the divisions:
function [dnondt] = DGm(R,T)
rhol = 3000;
m1 = 2.49e-25;
p = 2e5;
L = 798366.2;
cbg = 2057.97;
v1 = m1/rhol;
kb = 1.3807e-23;
mg = 2.989e-26;
mc = 2.49e-25;
K=0.0976;
s = 1.1;
cgbar = (((8*kb*T)./(pi*mg)))^(1/2);
Ps = exp(22.111-((m1*L)./(kb))/T);
ng = ((p)./(kb*T));
heat = ((m1^2*L^2)./(kb^2*T^2))*(((kb*R)/(K))+((4*kb)./(cbg*cgbar*ng*mg)));
nms = (Ps)./(kb*T);
cnbar = (((8*kb*T)./(pi*mc))).^(1/2);
D = 7.249e-5*((T^1.75)/(p));
mass =((4)/(nms*cnbar))*((1)+((R*cnbar)./(4*D)));
dnondt = 4*pi*R.^2*(s-1)./(heat+mass);
end
That worked when I plotted it.
Related Question