필터 지우기
필터 지우기

Reading only number from ,string mixed with numbers in a file

조회 수: 1 (최근 30일)
arun
arun 2017년 8월 10일
편집: arun 2017년 8월 10일
I'm reading a data file that FEM mesh data. Initial few like are:
  1. TITLE = "fluent13.0.0 build-id: 10703"
  2. VARIABLES = "X"
  3. "Y"
  4. DATASETAUXDATA Common.VectorVarsAreVelocity="TRUE"
  5. ZONE T="fluid"
  6. STRANDID=0, SOLUTIONTIME=0
  7. Nodes=25, Elements=16, ZONETYPE=FEQuadrilateral
  8. DATAPACKING=POINT
I want to extract only 25 and 16 from line number 7 as a number. Please provide the command for it.

채택된 답변

KSSV
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개)

카테고리

Help CenterFile Exchange에서 Large Files and Big Data에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by