# Rainflow Algorithm needs 3 samples

11 views (last 30 days)
Dominik on 17 Feb 2021
Answered: Abhimenyu on 31 May 2024
Hi,
I want to use the build-in rainflow(x,fs) algorithm to calculate the cycles a battery model has run by using it on the State of Charge (&) of the cell. When I try to use the algorithm on the SoC (see picture) I get the following error:
Input time series must have at least 3 samples.
But I set a sample rate fs and as you can see in the picture there is also enough data.
Anyone knows why?
##### 0 CommentsShow -2 older commentsHide -2 older comments

Sign in to comment.

### Answers (1)

Abhimenyu on 31 May 2024
Hi,
I understand that you are encountering an issue with the rainflow function, which is typically used for counting cycles in a signal, and often for fatigue analysis. The error message you're seeing suggests that the function is not receiving enough data points from the input. Please follow the below-mentioned reasons and recommendations to troubleshoot the issue:
1. Check Data Length: Ensure that the State of Charge (SoC) data series contains more than two data points. This can be done by checking the length or size of the data array. For example, in MATLAB, use length(data) or size(data,1) if your data is in a column vector. Verify that the data points are evenly spaced in time (i.e., consistent sample rate).
2. Verify Data Passed to Function: Make sure the data that is passed to the rainflow function is correctly referenced. Sometimes, a mistake in variable naming or indexing might lead to passing an empty array or a subset of the data that's too small. Check if there are any missing data points or irregularities in the dataset.
3. Sample Rate "fs": Ensure that the sample rate "fs" is correctly defined and passed to the function alongside your data. Ensure that the sample rate (fs) matches the actual time interval between data points in your State of Charge (SoC) dataset. If the sample rate is too high or too low, it could affect the number of samples available for the rainflow algorithm.
4. Data Format: The rainflow function expects the input time series data in a specific format (usually a vector). Ensure that the SoC data is in the correct format. If you're manipulating the data before passing it to the function, ensure these manipulations do not change the data's length unintentionally (e.g., turning it into a scalar or a 2-element array).
Please follow this MATLAB R2024a documentation link to understand more about the rainflow function: https://www.mathworks.com/help/signal/ref/rainflow.html
I hope this helps to resolve your query!
##### 0 CommentsShow -2 older commentsHide -2 older comments

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!