![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/668103/image.jpeg)
How can I plot a relative frequency histogram in Matlab?
19 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Eric Bernard Dilger
am 28 Jun. 2021
Kommentiert: William Rose
am 17 Mai 2022
I have developed a script to calculate the power fluctuation of a PV power plant. Basically, I'm calculating the magnitude of the power fluctuation dP, at an instant t, for a sampling period dt, as the difference between two power outputs, normalized to the nominal power Pnom of the plant, as follows:
dP( t ) = [ P( t + dt ) - P( t ) ] / Pnom.
I'm exporting 300 seconds of data from simulink to workspace and I want to plot relative frequency histograms for different sampling periods dt. Longer sampling timte dt implies in a smaller number of data inside this 300 seconds. So, i.e., for dt = 1 second I have 299 samples, for dt = 20 seconds, I have 280 samples. I have already calculated the power fluctuation dP( t ) and it can be observed in the figure below:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/668018/image.png)
The vertical axis describe the percentual power fluctuation and these values can be larger sometimes. I want to plot a figure that describes the relative frequency of these power fluctuations. The figure below (I took from a paper) represents the relative frequency plots I want to apply to my data.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/668023/image.png)
I appreciate any help!
0 Kommentare
Akzeptierte Antwort
William Rose
am 28 Jun. 2021
Matlab's histogram() command is nice. Attached script shows how you could use it. It produces the plot below.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/668103/image.jpeg)
4 Kommentare
THANGARASU P
am 17 Mai 2022
Bearbeitet: THANGARASU P
am 17 Mai 2022
Above concept really helps to find fluctuation...can you share me fluctutation reference material or published paper for reference
William Rose
am 17 Mai 2022
I am glad that the above concept and code are helpful for understanding and estimating fluctuation. The analysis of fluctuations above is not based on any particular references or journal articles. It is based on defining fluctuation as the absolute value of the fractional deviation from the mean value.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1001215/image.png)
One could define fluctuation differently, depending on the situation and goals. For example, you might choose not to take the absolute value. Or you might choose not to divide by the mean vaue of x. And so on. Those choices depend on what is most useful to you.
Weitere Antworten (1)
William Rose
am 28 Jun. 2021
The overlapping bars in the plot abve are potentially confusing to the viewer. Therefore I added some code to make a second plot, shown below. The data is the same, still presented as probabilities, but it is easier to understand, in my opinion. It is easy to modify this to show probabilities for more than two data sets. See attached code. The probabillities are different in this example because the random numbers are different on each run.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/668123/image.jpeg)
6 Kommentare
Siehe auch
Kategorien
Mehr zu Statistics and Machine Learning Toolbox finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!