2 views (last 30 days)

Show older comments

Good Afternoon,

I am trying to modify the following script

mu = 0.015; % mean particle size

sg = 1.6; % standard deviation

Ntot = 1000; % total number concentration of particles

nbins = 50; % number of bins

data = lognrnd(mu,sg,[Ntot,1]); % generate data

h = histogram(data,nbins); % display data as histogram

Nconcs = h.Values; % determine number concentration

rMin = min(data); % find the minimum particle radius in the distribution

rMax = max(data); % find the maximum particle radius in the distribution

rs = linspace(rMin,rMax,nbins); % create vector containing particle radii

scatter(rs,Nconcs); % plot data

I would like to be able to provide the values for minumum and maximum particle radius but receive a similar output. The trouble I am having is I cannot figure out a way of generating the random data between these values. Because the data does not have to be random I have also tried using lognpdf and providing the values...

mu = 0;

sg = 1;

rs = linspace(0.05:0.01:1.25); % range of particle radii

data = lognpdf(rs,mu,sg); % lognormal pdf

...after which I am finding myself getting stuck. Below I shall state what Inputs I have and the Outputs I am trying to acheive.

Inputs:

- mu and sg: the mean particle size and the standard deviation
- rMin and rMax: the minimum and maximum particle size
- Ntot: the total number concentration of particles

Outputs:

- rs: a vector containing particle radii (ideally lognormally spaced)
- Nconcs: a vector containing the approximate number concentration of each particle size corresponding to each element in rs
- figure(1) : a plot with rs on the x axis and Nconcs on the y axis (ideally with a lognormally spaced x-axis)
- figure(2): a histogram seperating radii into 50 bins of equal width showing the number concentration within each bin

I hope someone can help and i'm not missing anything too simple!!!

Jeff Miller
on 23 Feb 2021

What about something like this:

mu = 0.015; % mean particle size

sg = 1.6; % standard deviation

Ntot = 1000; % total number concentration of particles

nbins = 50; % number of bins

data = lognrnd(mu,sg,[Ntot,1]); % generate data

% only keep data from the range you want:

inRange = (data >= rMin) & (data <= rMax);

data = data(inRange);

h = histogram(data,nbins); % display data as histogram

Nconcs = h.Values; % determine number concentration

rMin = min(data); % find the minimum particle radius in the distribution

rMax = max(data); % find the maximum particle radius in the distribution

rs = linspace(rMin,rMax,nbins); % create vector containing particle radii

scatter(rs,Nconcs); % plot data

Jeff Miller
on 25 Feb 2021

Sorry I am not being helpful. I 'm not sure I understand this background and have nothing to add to my previous suggestion.

BTW, your code attempt for pdf does not look like a legal pdf to me, because I think it will integrate to Ntot, whereas pdfs should integrate to 1.

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

Start Hunting!