Reading only number from ,string mixed with numbers in a file
3 ビュー (過去 30 日間)
古いコメントを表示
I'm reading a data file that FEM mesh data. Initial few like are:
- TITLE = "fluent13.0.0 build-id: 10703"
- VARIABLES = "X"
- "Y"
- DATASETAUXDATA Common.VectorVarsAreVelocity="TRUE"
- ZONE T="fluid"
- STRANDID=0, SOLUTIONTIME=0
- Nodes=25, Elements=16, ZONETYPE=FEQuadrilateral
- DATAPACKING=POINT
I want to extract only 25 and 16 from line number 7 as a number. Please provide the command for it.
0 件のコメント
採用された回答
KSSV
2017 年 8 月 10 日
file = 'tec.txt';
fid = fopen(file,'r') ;
for i = 1:7
str = fgetl(fid) ;
end
fclose(fid) ;
p = regexp(str,'\d+','match') ;
iwant = str2double(p) ;
Nodes = iwant(1) ;
Elements = iwant(2) ;
0 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Data Import and Analysis についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!