Rainflow counting help - Trying to normalise or something
Show older comments
I was talking to my supervisor about this and we discussed how to do it. We want to divide by the total sum of the matrix. So e.g., let's say we have 1, 9 and 10 around. We would divide by (the sum) 20. Then, be left with 0.05, 0.45 and 0.5.
We would then divide by the area due to the bin size and then it would become 0.5, 4.5, and 5 e.g. This should hopefully give me a sort of graph that is colourful and in a shape with axes that are probably 1 by 1 (aspect ratio). Then we would compare all the shapes and see how they overlap with each other to get our final results.
I kind of understand it but have no clue on how I would code this in matlab. Do you have any idea on how to do this? I just know I have to get my colourful sort of contour map for all the different rainflow matrix that the area is all equal in size so they can be compared but they must be all in the same size done in a way that the results aren't skewed.

These are some more pictures of the goal and what I want to achieve.
Code:
fs = 100;
x = time data....
y = tensions data .... not puttong the numbers here way too many.
Z = [];
for k = 1:length(Y)-1
x = X(k+1)-X(k);
z = -(Y(k+1)-Y(k))*cos(pi*(0:1/fs:x-1/fs)/x)+Y(k+1)+Y(k);
Z = [Z z/2];
end
Z = [Z Y(end)]
t = linspace(X(1),X(end),length(Z));
plot(X,Y,"o",t,Z)
[c,hist,edges,rmm,idx] = rainflow(Z,t);
TT = array2table(c,VariableNames=["Count" "Range" "Mean" "Start" "End"]);
Count = c(:,1);
Range = c(:,2);
Mean = c(:,3);
% NORMALISE AXES
Tmean = mean(Z);
Trange = max(Z) - min(Z);
Mean_norm = (Mean - Tmean) / Trange + 0.5;
Range_norm = Range / Trange;
Mean_norm = (Mean - min(Z)) / (max(Z) - min(Z));
Range_norm = Range / (max(Z) - min(Z));
nbins = 40;
[N,mean_edges,range_edges] = histcounts2(Mean_norm,Range_norm,nbins);
% Normalise by total cycles
N_norm = N / sum(N(:));
% Divide by bin area
dMean = mean_edges(2) - mean_edges(1);
dRange = range_edges(2) - range_edges(1);
bin_area = dMean * dRange;
N_density = N_norm / bin_area;
mean_centres = (mean_edges(1:end-1) + mean_edges(2:end))/2;
range_centres = (range_edges(1:end-1) + range_edges(2:end))/2;
figure
contourf(mean_centres,range_centres,N_density,20,'LineColor','none')
colorbar
colormap(turbo)
xlabel('Normalised Mean')
ylabel('Normalised Range')
title('Normalised Rainflow Density')
axis square
axis([0 1 0 1])
Does anyone have any suggestions on how to achieve this at all ? First time using matlab as thought it would be easier for rainflow analysis. This is what is gives me now anyways.

Answers (1)
Christopher Stapels
on 16 Mar 2026 at 20:21
0 votes
I suggest you normalize by the maximum number in a dimension an not by the sum. So by your example, 1, 9 and 10 would become 0.1, 0.9, and 1.
Can you provide some background data on what you are measuring and what the goal of the expirament is? Keep it simple if you can please. Then we can help you gereate the code to do what you want. MATLAB is a great place to start - its designed to make things as easy as possible.
4 Comments
Christopher Stapels
on 17 Mar 2026 at 13:37
For example, where you say "discussed how to do it." please define what you man by 'it'
Oscar
on 17 Mar 2026 at 14:30
Christopher Stapels
on 17 Mar 2026 at 15:16
So you are measuring tension in a boat mooring line over time?
Is rainflow just the type of chart or are you measuring how the mooring line for the boat does when it rains?
I understand that you are trying to compare between graphs with large difference in scale. I feel normalizing them to a max may allow you to compare the shape but you will loose information about the magnitude. You might try plotting on a log scale, but that may also induce some confusion.
Perhaps if we understand more about the experiment it will help decide what you can do to compare the data. For example if you are stress testing the mooring lines to find a breaking point, then mormalizing them will oose the main break tension. But if you are just hoping to learn about wear over time, perhaps the absolute magnitude is less important.
Oscar
on 19 Mar 2026 at 21:26
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!