Obtaining the nastan node table

1 view (last 30 days)
Prasad Tapkir
Prasad Tapkir on 21 Jan 2019
Answered: V San on 11 Feb 2021
I have a cell of nastran file.
node= 'grid node number coordinate'
how do I split it so I can convert into multiple column format (considering spaces)

Answers (1)

V San
V San on 11 Feb 2021
You would just have to open and then read the node data file line by line using the standard matlab functions, define a condition with a keyword such as "GRID" so the code identifies the line that contains the information you wish to read. Then specify the character location range (column number) to assign it as a string to a variables. You may have to convert the format if you wish to do calculations, etc with these strings. Code should look something like the one below. This is just a sample. It would generally require some tweeking to fit your file. Cheers!
Note:
  1. Nastran files have standard "CARD" format and character allocations to make this type of read/write tasks pretty general
  2. Column numbers of characters are displayed in Notepad/Notepad++ in the lower right
fid=fopen(filename);
status=fseek(fid111,0,'eof');
EOF=ftell(fid111);
currentFPI=fseek(fid111,0,'bof');
while currentFPI<EOF
linestr=fgetl(fid111);currentFPI=ftell(fid111);
str=findstr(linestr(1:4),'GRID'); % (1:4) is just an example. Specify correct character location (column number)
XX=77 % max line length
if length(linef06)>=XX && isempty(str)==0 % you may need to specify different conditions here to make sure ONLY the required lines are being read
linef06=fgetl(fid111);currentFPI=ftell(fid111);
% linef06=fgetl(fid111);currentFPI=ftell(fid111);
% each fgetl command takes you to next line. Make sure you use the required number of "fgetl"
% (i.e. no lines with required data are missed or lines with wrong data is read)
gridnum=str2num(linestr(1:4));
% similarly other data columns
end
end
fclose(fid);

Categories

Find more on Creating, Deleting, and Querying Graphics Objects 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!