-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPredictiveAi.m
84 lines (69 loc) · 2.37 KB
/
PredictiveAi.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
%setup database
folder_path = 'C:\Users\hey\OneDrive\Bureau\Predictive Ai\database';
files = dir(folder_path);
for i = 1:length(files)
if ~files(i).isdir
file_path = fullfile(folder_path, files(i).name);
load(file_path);
end
end
%excrate data
numExperiments = 2;
% Names of the original data files restored from the zip archive.
files = [ ...
"struct_rs_R1.mat", ...
"struct_r1b_R1.mat", ...
"struct_r2b_R1.mat", ...
"struct_r3b_R1.mat", ...
"struct_r4b_R1.mat", ...
];
% Rotor conditions (that is, number of broken bars) corresponding to original data files.
health = [
"healthy", ...
"broken_bar_1", ...
"broken_bar_2", ...
"broken_bar_3", ...
"broken_bar_4", ...
];
Fs_vib = 7600; % Sampling frequency of vibration signals in Hz.
Fs_elec = 50000; % Sampling frequency of electrical signals in Hz.
%test database befor starting
folder = 'data_files';
if ~exist(folder, 'dir')
mkdir(folder);
end
%data files for each broken rotor bar condition
% Iterate over the number of broken rotor bars.
for i = 1:numel(health)
fprintf('Processing data file %s\n', files(i))
% Load the original data set stored as a struct.
S = load(files(i));
fields = fieldnames(S);
dataset = S.(fields{1});
loadLevels = fieldnames(dataset);
% Iterate over load (torque) levels in each data set.
for j = 1:numel(loadLevels)
experiments = dataset.(loadLevels{j});
data = struct;
% Iterate over the given number of experiments for each load level.
for k = 1:numExperiments
signalNames = fieldnames(experiments(k));
% Iterate over the signals in each experimental data set.
for l = 1:numel(signalNames)
% Experimental (electrical and vibration) data
data.(signalNames{l}) = experiments(k).(signalNames{l});
end
% Operating conditions
data.Health = health(i);
data.Load = string(loadLevels{j});
% Constant parameters
data.Fs_vib = Fs_vib;
data.Fs_elec = Fs_elec;
% Save memberwise data.
name = sprintf('rotor%db_%s_experiment%02d', i-1, loadLevels{j}, k);
fprintf('\tCreating the member data file %s.mat\n', name)
filename = fullfile(pwd, folder, name);
save(filename, '-v7.3', '-struct', 'data'); % Save fields as individual variables.
end
end
end