필터 지우기
필터 지우기

Obtaining the nastan node table

조회 수: 4 (최근 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에서 Text Data Preparation에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by