Input files editing format

1 view (last 30 days)
Hi, Good morning
I have an input file input.txt, i need to save the format in different two files node.txt and el.txt in the format attached files. Any help would be appreciated . Thank you inadvance.
  2 Comments
Mario Malic
Mario Malic on 18 Jan 2021
What is the actual question here?
RAKESH KUMAR TOTA
RAKESH KUMAR TOTA on 18 Jan 2021
i need to extract data from input.txt file ( nodes and element data) and save in the format node.txt and el.txt as mentioned in the uploaded files. Thank you.

Sign in to comment.

Accepted Answer

Walter Roberson
Walter Roberson on 18 Jan 2021
fid = fopen('input.txt', 'r');
nodedata = cell2mat( textscan(fid, '%*f,%f,%f', 'CommentStyle', {'*Heading', '*Node'}) );
eldata = cell2mat( textscan(fid, '%*f,%f,%f,%f,%f', 'HeaderLines', 1) );
fclose(fid)
  8 Comments
RAKESH KUMAR TOTA
RAKESH KUMAR TOTA on 18 Jan 2021
Thanks a lot . It really saved a lot of time.
RAKESH KUMAR TOTA
RAKESH KUMAR TOTA on 18 Jan 2021
eldata (:, 1) = 1; % why ??? ... I need to assign materail no.1 to all elements in my code. Thank you

Sign in to comment.

More Answers (0)

Categories

Find more on Data Import and Export in Help Center and File Exchange

Products


Release

R2020b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!