Error Using Rainflow fonction
8 ビュー (過去 30 日間)
古いコメントを表示
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
0 件のコメント
回答 (2 件)
Animesh
2024 年 7 月 29 日
編集済み: Animesh
2024 年 7 月 29 日
Hey @JoeTeg
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
2024 年 7 月 29 日
Hey @JoeTeg
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);
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')
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]
figure
rainflow(Z(:,1),t)
sgtitle(VN{7})
figure
rainflow(Z(:,2),t);
sgtitle(VN{6})
.
4 件のコメント
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 Center および File Exchange で Vibration Analysis についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!