matlab reads the.geo file
10 次查看(过去 30 天)
显示 更早的评论
Hello!I have a.geo file, I want to extract all the information in it in matlab, all the Point, Line, Line Loop, Plane Surface, how can I extract the following data according to its string in matlab and convert it into a matrix。
2 个评论
采纳的回答
Voss
2022-12-18
Here's one way:
fid = fopen('rec.txt','r');
text = fread(fid,'*char').';
fclose(fid);
data = regexp(text,'([\w ]+)\((\d+)\) = {(.+?)}','tokens');
data = vertcat(data{:});
data(:,1) = strrep(data(:,1),' ','_');
data(:,[2 3]) = cellfun(@str2num,data(:,[2 3]),'UniformOutput',false);
args = unique(data(:,1)).';
args(end+1,:) = {[]};
result = struct(args{:});
for ii = 1:size(data,1)
result.(data{ii,1}) = subsasgn( ...
result.(data{ii,1}), ...
substruct('()',{data{ii,2},':'}), ...
data{ii,3});
end
result
result.Point
result.Line
result.Line_Loop
result.Plane_Surface
0 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Import, Export, and Conversion 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!