binwidth is not working

10 ビュー (過去 30 日間)
Mohamed Zied
Mohamed Zied 2023 年 1 月 2 日
コメント済み: Mohamed Zied 2023 年 1 月 4 日
Hi;
%statistical parameters
STD_Strain = 25;
Mean_strain = 150;
AN=1000;
Stress = 210000*(STD_Strain.*randn(AN,1) + Mean_strain)*10^-6;
%Stress range-rainflow counting
[c,hist,edges,rmm,idx]=rainflow(Stress)
BinWidth=2;
h=histogram('BinEdges',edges','BinCounts',sum(hist,2))
xlabel('Stress Range')
ylabel('Cycle Counts')
The target of this code is to conduct fatigue analysis.
I tried by many ways to specify the bin width. Still, the result is always bin width = 3.
h =
Histogram with properties:
Data: []
Values: [64 54.5000 67 47.5000 36 27 19 6.5000 5 1 1.5000]
NumBins: 11
BinEdges: [0 3 6 9 12 15 18 21 24 27 30 33]
BinWidth: 3
BinLimits: [0 33]
Normalization: 'count'
FaceColor: 'auto'
EdgeColor: [0 0 0]
What is wrong with my code?
Thank you in advance
  3 件のコメント
Rik
Rik 2023 年 1 月 4 日
It is an internal function: rainflow doc page, so modifying it should be avoided. I can't see from the documentation how you can extract the actual values or force it to use a specific binning.
Voss
Voss 2023 年 1 月 4 日
My mistake. Thanks for pointing that out.

サインインしてコメントする。

回答 (1 件)

Rik
Rik 2023 年 1 月 2 日
編集済み: Rik 2023 年 1 月 3 日
You're just creating a variable. You do not use that variable as an input argument, or to modify the histogram object after you create it. How is Matlab supposed to know you meant that?
edit:
Below are the two possible ways you can change the code. However, neither will work, because you manually set the bin counts.
%statistical parameters
STD_Strain = 25;
Mean_strain = 150;
AN=1000;
Stress = 210000*(STD_Strain.*randn(AN,1) + Mean_strain)*10^-6;
%Stress range-rainflow counting
[c,hist,edges,rmm,idx]=rainflow(Stress);
BinWidth=2;
h=histogram('BinEdges',edges','BinCounts',sum(hist,2));
xlabel('Stress Range')
ylabel('Cycle Counts')
if false
% option 1:
h.BinWidth=BinWidth;
% option 2:
h=histogram('BinEdges',edges','BinCounts',sum(hist,2),'BinWidth',BinWidth);
end
  3 件のコメント
Rik
Rik 2023 年 1 月 3 日
The fundamental problem is that you don't provide the original source data to the histogram function, so it can't split bins for you.
You need to explain what exactly the source data is. Then you can use the histogram function as it is intended to be used, instead of a fancier version of the bar function.
Mohamed Zied
Mohamed Zied 2023 年 1 月 4 日
thank you for you answer.
actually, I am preparing a code to conduct a fatigue analysis based on monitoring. That's why, I generated monitored strain data using the randn function just to verify the code. Later on my research, I intend to conduct monitoring on a real bridge.
I want to control the bin width (stress range) to easily use Miner's rule later.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeStress and Strain についてさらに検索

タグ

製品


リリース

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by