Why is there no plot on my figure?

I am trying to produce a graph of cloud height against albedo. A figure appears but no plot and I can't work out why. Thank you.
%number of droplets
N= 1120e6;
%cloud height
h= [0:1:1000];
%asymmetry parameter
g=0.858;
figure
semilogx(h,a(t(N,r(N),h),g))
function albedo = a(t,g)
% returns the cloud albedo from the measure of optical depth and asymmetry
albedo = ((1-g)*t)/(2+(1-g)*t);
end
function radius = r(n)
%returns the effective radius of the cloud droplets given the water content
% and droplet number
radius= ((3e-4*3)/(1000*4*n*pi))^(1/3);
end
function optical_depth= t(n,r,h)
%returns the optical depth of a cloud from the assumptions in Twomey 1977
optical_depth= 2*pi*n*r^2*h;
end

Réponses (2)

KSSV
KSSV le 1 Fév 2019
Modifié(e) : KSSV le 1 Fév 2019
YOu are generating only a point data with the functions.....So you have to use a marker.
Try:
semilogx(h,a(t(N,r(N),h),g),'*r')
madhan ravi
madhan ravi le 1 Fév 2019
Modifié(e) : madhan ravi le 1 Fév 2019
albedo = ((1-g)*t)./(2+(1-g)*t);
% ^------ missed it

3 commentaires

EmHat
EmHat le 1 Fév 2019
This worked! Why is the dot necessary?
madhan ravi
madhan ravi le 1 Fév 2019
Reason: Since t is a vector each element is divided by each element.
It's called element-wise operation see https://www.mathworks.com/help/matlab/matlab_prog/array-vs-matrix-operations.html - for better learning and understanding.
EmHat
EmHat le 1 Fév 2019
Amazing! Thank you!

Connectez-vous pour commenter.

Produits

Version

R2018b

Question posée :

le 1 Fév 2019

Commenté :

le 1 Fév 2019

Community Treasure Hunt

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

Start Hunting!

Translated by