Irregular data txt, excel extraction
Version 1.0.0 (52.4 KB) by
Shengjie Ren
Irregular data txt, excel extraction
clc
%% 读取原始数据txt文本
x1=readtable ("old_data.txt");
x2=table2array(x1);%转化为cell
%% 提取x y z 坐标
for i=1:5:size(x2,1)
x3(i,1) =x2(i,1);
end %提取第一列
x3(cellfun(@isempty,x3))=[];%删除空矩阵
for i=1:length(x3)
x{i}=str2num(x3{i});
end
for i=1:length(x)
x4(i,:)=x{i};
end %cell转double
zuobiao=x4(:,2:end);
%% 提取stress应力值
for i=3:5:size(x2,1)
x5(i,1) =x2(i,1);
end %提取第一列
x5(cellfun(@isempty,x5))=[];%删除空矩阵
writecell(x5,'F:\admin\RenSJ\Matlab\export_stress\N_data.txt','Delimiter','tab');%保存为N_data.txt准备再次提取,这两行结果一样
[stress]=textread('.\N_data.txt','%*s %*s %f') ;%读取文件N_data.txt,%*s表示跳过两个英文读单词,%f读取第三列数字
%% 合并X Y Z 以及stress值并保存为data.txt
data=[zuobiao stress]; %目标数据
writematrix(data,'F:\admin\RenSJ\Matlab\export_stress\new_data.txt','Delimiter','tab')
delete('N_data.txt')
Cite As
Shengjie Ren (2024). Irregular data txt, excel extraction (https://www.mathworks.com/matlabcentral/fileexchange/103200-irregular-data-txt-excel-extraction), MATLAB Central File Exchange. Retrieved .
MATLAB Release Compatibility
Created with
R2021b
Compatible with any release
Platform Compatibility
Windows macOS LinuxTags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Discover Live Editor
Create scripts with code, output, and formatted text in a single executable document.
Version | Published | Release Notes | |
---|---|---|---|
1.0.0 |