clc
clear
%% Step 1: 读入数据
phasedata = readtable('phasedata.txt');
%% Step 2: 提取数据
time = phasedata(:,1); % 提取地址
time= table2cell(time); % 转换数据类型
phase = phasedata(:, 8); % 提取相位
phase = table2cell(phase);
%% Step 3: 预处理数据
len = length(time); % 返回数据长度
matchData = regexp(time, '^[.*]', 'split'); % 裁剪数据
%% Step 4:提取处理过后的数据
idStr = cell(len, 1);
for i=1:len
idStr{i} = matchData{i}{2};
end
phase = regexprep(phase, 'A', '1');
phase = regexprep(phase, 'B', '2');
phase = regexprep(phase, 'C', '3');
%% Step 5: 输出数据
id = cell2table(idStr);
phase = cell2table(phase);
newTable = [id, phase];
writetable(newTable,'myData.txt','Delimiter',' ','WriteVariableNames', false);