标签:clear data RoCE 图片 type src rcm 循环 文本
基于matlab计步
%对原始观测得到的数据进行获取
clc, clear;
%加速度数组
accspe_data = [];
time_record = [];
fid=fopen(‘sensor_normal.txt‘, ‘r‘, ‘n‘, ‘utf-8‘);
%初始赋值使循环开始
tline = 1;
%对文本进行循环读入
%line = ‘owieo‘;
while tline
%fgetl获取某一行
tline=fgetl(fid);
%转换编码形式
tline = native2unicode(tline);
%enc = detect_encoding(tline)
%转换为char类型
line = char(tline);
%对值进行输出
%disp(line);
%提取的数据
% data = regexp(line, ‘:‘, ‘split‘);
%disp(line);
%disp(length(line));
% res = ‘‘;
% % for len = 1:length(line)
% % res = strcat(res,line(len)); %字符串相加
% % %disp(‘oiwei‘);
% end
data = strsplit(line, ‘:‘);
%从字符串中提取所需要的数据
if strcmp(data(1), ‘加速度‘)
volecity = data(2);
vole = strsplit(char(volecity));
%disp(vole);
vole_x = str2double(vole(2));
vole_y = str2double(vole(3));
vole_z = str2double(vole(4));
vole_res = sqrt(power(vole_x, 2) + power(vole_y, 2) + power(vole_z, 2));
accspe_data = [accspe_data, vole_res];
end
if strcmp(data(1), ‘时间‘)
time = strcat(data(2), data(3), data(4));
time_data = strsplit(char(time));
time_record = [time_record, (time_data(3))];
end
% end
%print(‘oiweoi‘)
%print(class(tline));
%提取其中的数据
end
%判断是否缺少数据
len = length(time_record);
time_check = ones(1, len);
for num = 1:len
time_num = str2double(char(time_record(num)));
hour = floor(time_num / 10000);
minute = floor((time_num - hour * 10000) / 100);
second = floor((time_num - hour * 10000 - minute * 100));
%将时间转换为秒
time_check(num) = hour * 3600 + minute * 60 + second;
if num >= 2 && (time_check(num) - time_check(num - 1)) > 1
disp(‘数据采集有误,部分数据缺失!!!‘);
disp(time_check(num) - time_check(num - 1)) ;
end
end
fclose(fid);
版本:2014a
完整代码或代写加1564658423
【物理应用】基于matlab计步【含Matlab源码 524期】
标签:clear data RoCE 图片 type src rcm 循环 文本
原文地址:https://www.cnblogs.com/homeofmatlab/p/14941945.html