zoukankan      html  css  js  c++  java
  • Matalb 正则表达式预处理数据(一)

    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);
    
  • 相关阅读:
    通过dockerfile制作nginx镜像
    docker存储卷
    docker容器网络配置
    状态模式
    抽象工厂模式
    观察者模式
    建造者模式
    外观模式
    模板方法模式
    原型模式
  • 原文地址:https://www.cnblogs.com/mysterygust/p/14850076.html
Copyright © 2011-2022 走看看