Error Using Rainflow fonction

6 次查看(过去 30 天)
JoeTeg
JoeTeg 2024-7-29
Hello everyone,
I'm not really good at Matlab, but I need to use it to process some load cycles result using the rainflow function (please see attachment)
I have written the code as below
clear all,
clc,
[filename,pathname] = uigetfile({'*.xlsx;*.xlsm','Excel Worksheets (*.xlsx,*.xlsm)'},'Select File');
[file,sheets] = xlsfinfo([pathname,filename]);
num_1 = xlsread(filename);
[num_3, txt]= xlsread(filename);
%read only row and column with number
Data_1 = num_3(4:end,:); % 4:end, --> choose all the row start from 4 % : --> choose all the column % start at row 4 and read all column
X = num_3(4:end,7); % 4,--> Choose only row 4 seread oly row 4 and all column.
Y = num_3(4:end,6);
Z = num_3(4:end,8);
figure(1)
plot3(X,Y,Z);
t = linspace(min(Y),max(Y),length(Z)/10);
d = linspace(min(Y),max(Y),length(Z)/5);
figure(2)
Z = [X Y]
rainflow(Z,t);
and unfortunately have the errors below after the code:
Error using rainflow
Expected X to be a vector.
Error in rainflow>parseInputs (line 184)
validateattributes(x,{'single','double'},...
Error in rainflow (line 81)
[x,t,ext,td] = parseInputs(x,varargin{:});
Error in KW31_BMW_Load_Cycle_Ju (line 39)
rainflow(Z,t)
Can someone please tell me were I´making the mytake by using the Rainflow function?
Thank in advance

回答(2 个)

Animesh
Animesh 2024-7-29
编辑:Animesh 2024-7-29
The "rainflow" function is typically used for fatigue analysis and expects a time history of stress or strain as input. Thus the provide input should be a vector.
The current code is passing a matrix "Z" composed of "X" and "Y" values, making "Z" a 51 x 2 matrix, which is unsuitable for the "rainflow" function.
If you wish to concatenate data of "X" and "Y", try using "vertcat" function to concatenate them vertically.
Z = vertcat (X,Y)
You can refer the following MathWorks documentation for more information :
  3 个评论
Animesh
Animesh 2024-7-29
From what I can gather, you want to evaluate three load cycles together. The "rainflow" function in MATLAB is designed to process a single vector of data, typically a time history of stress or strain. It cannot directly handle three separate vectors like "X", "Y", and "Z" simultaneously.
Here's a way to approach it: combine the data. If you need to evaluate the load cycles for the combined data, you need to create a single vector that represents the load history. This could be done by concatenating the vectors "X","Y", and "Z" in a meaningful way.
% Read only row and column with number
Data_1 = num_3(4:end, :); % 4:end, --> choose all the rows starting from 4 % : --> choose all the columns
X = num_3(4:end, 7); % Column 7
Y = num_3(4:end, 6); % Column 6
Z = num_3(4:end, 8); % Column 8
% Combine X, Y, Z into a single vector
combinedData = [X; Y; Z];
Also make sure that the time vector "t" has same dimensions as the transpose of "combinedData".
t=linspace(0, length(combinedData)-1, length(combinedData));
Now, you can evaluate "rainflow" on this data:
rainflow(combinedData, t);
JoeTeg
JoeTeg 2024-7-29
thank a lot @Animesh for taking from your time to help me. I really appreciate it. I will try the code a let you know if i stil have some questions.

请先登录,再进行评论。


Star Strider
Star Strider 2024-7-29
The rainflow function only takes vector arguments.
What result do you want?
In the interim,try this —
T1 = readtable('Data_for_Rainflow.xlsx', 'VariableNamingRule','preserve')
T1 = 52x8 table
Zeit Pressure_1 Pressure_2 Masse Flow Pressure_3 adiabatic power Normlize Load Cycle 1 to 3 ____ __________ __________ __________ __________ _______________ _____________ ____________ NaN NaN NaN NaN NaN NaN NaN NaN 0 102.01 97.432 5.0249 1.0747 0.031449 0.023871 1 0.5 140.42 111.94 36.53 1.486 1.3174 1 2 1 140.41 111.94 36.511 1.4859 1.3167 0.99942 3 1.5 139.69 111.58 35.947 1.478 1.2779 0.97 1 2 138.72 111.1 35.198 1.4675 1.2271 0.93142 2 2.5 137.88 110.68 34.546 1.4584 1.1836 0.89844 3 3 137.17 110.33 33.991 1.4506 1.1472 0.8708 1 3.5 136.5 110.03 33.446 1.4433 1.1127 0.84463 2 4 135.89 109.78 32.948 1.4368 1.082 0.82129 3 4.5 135.18 109.48 32.375 1.4292 1.0468 0.79459 1 5 134.48 109.18 31.809 1.4217 1.0127 0.76866 2 5.5 133.86 108.91 31.301 1.415 0.98236 0.74566 3 6 133.26 108.66 30.817 1.4086 0.95389 0.72405 1 6.5 132.94 108.52 30.556 1.4052 0.9388 0.7126 2 7 132.7 108.42 30.361 1.4026 0.92756 0.70406 3
VN = T1.Properties.VariableNames;
num_3 = T1{2:end,:};
X = num_3(:,7); % 4,--> Choose only row 4 seread oly row 4 and all column.
Y = num_3(:,6);
Z = num_3(:,8);
t = num_3(:,1);
figure(1)
plot3(X,Y,Z);
grid on
xlabel(VN{7})
ylabel(VN{6})
zlabel(VN{8})
% t = linspace(min(Y),max(Y),length(Z)/10);
d = linspace(min(Y),max(Y),length(Z)/5);
figure(2)
Z = [X Y]
Z = 51x2
0.0239 0.0314 1.0000 1.3174 0.9994 1.3167 0.9700 1.2779 0.9314 1.2271 0.8984 1.1836 0.8708 1.1472 0.8446 1.1127 0.8213 1.0820 0.7946 1.0468
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
figure
rainflow(Z(:,1),t)
sgtitle(VN{7})
figure
rainflow(Z(:,2),t);
sgtitle(VN{6})
.
  4 个评论
JoeTeg
JoeTeg 2024-7-29
Thx i will try it and come back to you with more detaisl. It is also the first time for me to process such kind of data
i wish you a nice evening
Star Strider
Star Strider 2024-7-29
Thank you!
I have never needed to use that function either, ono my own data. I am learning as well.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Vibration Analysis 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by