Obtaining the nastan node table

1 次查看(过去 30 天)
Prasad Tapkir
Prasad Tapkir 2019-1-21
回答: V San 2021-2-11
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)

回答(1 个)

V San
V San 2021-2-11
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);

类别

Help CenterFile Exchange 中查找有关 Creating, Deleting, and Querying Graphics Objects 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by