How can I read in specific parts of an .inp file
9 views (last 30 days)
Show older comments
I'm trying to use the finite element method in matlab for the first time, new to both subjects, and I'm struggling to parse data from an .inp file of just numbers. the first two lines of numbers are for establishing material properties, after which there is a list of 8 nodes with their coordinates, then the 7 elements and their connections. I am looking for a way to read in and store the nodes' number and coordinates, but do not know how to have matlab scan just a specific section of the input file.
Any help would be appreciated.
2 Comments
Answers (1)
Voss
on 28 Sep 2021
There are many functions you can use to read text files. If you have a fixed number of lines you always want to skip before the lines you want to read, you can use fgetl.
fid = fopen('file.inp');
for i = 1:2
fgetl(fid); % read line and do nothing with it
end
data = fgetl(fid); % first line of relevant text
% ... and so on
fclose(fid);
0 Comments
See Also
Categories
Find more on String Parsing 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!