Assign width of Bin Edges within rainflow matrix c = rainflow(x)

33 views (last 30 days)
Is it possible to specify the width of Bin Edges when calculating the rainflow cycle counts matrix c = rainflow(x) ?
After computing the cycle counts for the data, using the command: [c,hist,edges,rmm,idx] = rainflow(Y) , I plot a histogram of cycle counts as a function of stress range, using the command: histogram('BinEdges',edges','BinCounts',sum(hist,2)) , as indicated in the example of the Matlab Documentation
It seems that the 'Bin Edges' are assigned an arbitrary width value. Instead, I would like to assign a specific width value to the Bin Edges, while ploting the histogram of the cycle counts, resulting from the cycle counts matrix 'c = rainflow(x)'.
How can we specify the width of Bin Edges when calculating the rainflow cycle counts matrix 'c = rainflow(x)' ?
Thank you very much in advance for your help

Answers (1)

Steven Lord
Steven Lord on 25 Jun 2019
As written, the BinWidth property of the histogram object is determined by the BinEdges that you specified when you called histogram.
x = randn(1, 1e5);
E = [-3 -2 -1.25 -0.5 0 0.5 1.25 2 3];
h = histogram(x, 'BinEdges', E);
h.BinWidth
oldEdges = h.BinEdges
To change the BinWidth before the fact, change your BinEdges. To change the BinWidth after the fact, set it. This will affect the BinEdges property.
h.BinWidth = 1;
newEdges = h.BinEdges
  5 Comments
Nandar Hlaing
Nandar Hlaing on 16 Feb 2021
@Max Rose Thank you very much. It is really helpful.
I just have an additional curosity. If I don't want to have the same binwidth for all bins, it is still okay if I directly define edgesx as I prefer right?
Max Rose
Max Rose on 17 Feb 2021
I didn't try by myself but actually thats what is done in:
n_edges=101;
binWidth=0.01;
for i=1:n_edges
edgesx(1,i)=(i-1)*binWidth;
end
There the edges are defined, so I think it should work. So give it a try and let us know.

Sign in to comment.

Categories

Find more on Vibration Analysis in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!