Reading in 8 and then 16 characters using regexp on one line - NASTRAN data file
2 views (last 30 days)
Show older comments
So I'm writing a program that reads in NASTRAN data file entries. Usually you could read it in 8 characters at a time to get the right numbers, or if it's separated by commas I could use regexp split. However, sometimes it looks like this:
The * entries are 8 characters and then 16 for everything after. The other examples shown like PBAR and CTRIA3 can be read in 8 characters at a time throughout. If I have it so that the first line is a 1x60 char in the first column of a 700000x2 cell and the second line is a 1x44 char in the second column, how can I separate the values into a 1x5 cell in the first column and a 1x4 cell in the second column of a different variable?
I'm mostly asking how to read in 8 characters for the first word and then 16 for every number after if I normally do this for 8 characters:
tok=regexp(all,'.{1,8}','match');
I'm doing the following if "all" is the 700000x2 cell and separate does something like the line above depending on the type of entry:
[~, width]=size(all);
for i=1:width
All(:,i)=cellfun(@separate,all(:,i), 'UniformOutput', false);
end
Any advice on how to do this better is appreciated as well. Also note that it isn't always 4 numbers after the entry name (it can be up to 9 but sometimes only 1)
0 Comments
Accepted Answer
More Answers (0)
See Also
Categories
Find more on Data Import and Analysis in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!