Reputation: 5569
I have a vector named speed
containining the speed of 200 walks
speed = [normrnd(80,2,100,1); normrnd(120,10,100,1)];
This vector follows a bimodal distribution.
steps
is another vector contaning the number of steps for each walk:
a = 8;
b = 100;
steps = (b-a).*rand(200,1) + a;
I create the histgram plot of the steps performed in function of the speed:
binstep = 1.5;
binranges = (min(speed):binstep:max(speed)+binstep)';
[~, ind] = histc(speed, binranges);
bincounts = accumarray(ind, steps, size(binranges));
hFig = figure(); axh = axes('Parent', hFig); hold(axh, 'all'); grid(axh, 'on');
bar(axh, binranges, bincounts); axis(axh, 'tight');
Now I would like to
Could you please help me?
Upvotes: 0
Views: 930
Reputation: 5212
To fit data to distributions just use the fitdist function. In your case, with a Normal it would be:
pd = fitdist(y,'Normal')
Upvotes: 0