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

Antworten (2)

KSSV
KSSV am 1 Feb. 2019
Bearbeitet: KSSV am 1 Feb. 2019

0 Stimmen

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 am 1 Feb. 2019
Bearbeitet: madhan ravi am 1 Feb. 2019

0 Stimmen

albedo = ((1-g)*t)./(2+(1-g)*t);
% ^------ missed it

3 Kommentare

EmHat
EmHat am 1 Feb. 2019
This worked! Why is the dot necessary?
madhan ravi
madhan ravi am 1 Feb. 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 am 1 Feb. 2019
Amazing! Thank you!

Melden Sie sich an, um zu kommentieren.

Produkte

Version

R2018b

Gefragt:

am 1 Feb. 2019

Kommentiert:

am 1 Feb. 2019

Community Treasure Hunt

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

Start Hunting!

Translated by