- Nastran files have standard "CARD" format and character allocations to make this type of read/write tasks pretty general
- Column numbers of characters are displayed in Notepad/Notepad++ in the lower right
Obtaining the nastan node table
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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)
0 Kommentare
Antworten (1)
V San
am 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:
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);
0 Kommentare
Siehe auch
Kategorien
Mehr zu Text Data Preparation finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!