creating variables or an array from a complex text files

조회 수: 1 (최근 30일)
fadzhi
fadzhi 2016년 8월 12일
답변: Swathik Kurella Janardhan 2016년 8월 16일
Hi all matlab Gurus, I need to parse a complex text file that is currently giving me the stress and strain histories for a FEM simulation. I am a newbie to MATLAB and having real difficulties arranging the file in desired way. The structure of the file is
e l e m e n t s t r e s s c a l c u l a t i o n s f o r t i m e s t e p 1 ( at time 0.00000E+00 )
element materl(local)
ipt-shl stress sig-xx sig-yy sig-zz sig-xy sig-yz sig-zx plastic
state strain
23044- 6
1- 16 elastic 0.0000E+00 0.0000E+00 0.0000E+00 0.0000E+00 0.0000E+00 0.0000E+00 0.0000E+00
2- 16 elastic 0.0000E+00 0.0000E+00 0.0000E+00 0.0000E+00 0.0000E+00 0.0000E+00 0.0000E+00
3- 16 elastic 0.0000E+00 0.0000E+00 0.0000E+00 0.0000E+00 0.0000E+00 0.0000E+00 0.0000E+00
4- 16 elastic 0.0000E+00 0.0000E+00 0.0000E+00 0.0000E+00 0.0000E+00 0.0000E+00 0.0000E+00
5- 16 elastic 0.0000E+00 0.0000E+00 0.0000E+00 0.0000E+00 0.0000E+00 0.0000E+00 0.0000E+00
strains (local) eps-xx eps-yy eps-zz eps-xy eps-yz eps-zx
23044- 6
lower ipt 0.0000E+00 0.0000E+00 0.0000E+00 0.0000E+00 0.0000E+00 0.0000E+00
upper ipt 0.0000E+00 0.0000E+00 0.0000E+00 0.0000E+00 0.0000E+00 0.0000E+00
I have these output for about 1000 time steps. I need to arrange the time step, and and 12 variables (sigxx, sigyy, sigzz, sigxy, sigyz, sigzx, epsxx,epsyy, epszz, epsxy,epsyz, epszx) for each integration point (1,2,3,4,5) for stress and lower ipt and upper ipt in case of strain to separate variables. Can somebody guide me in the right way. Will really appreciate the help as i am losing a lot of time on it. Best Regards, FAWAD
  댓글 수: 1
Miyuru K
Miyuru K 2016년 8월 12일
Attaching a sample file would be helpful. This should probably work with fopen, textscan, fclose. And iterate for 1000 files/steps?

댓글을 달려면 로그인하십시오.

답변 (1개)

Swathik Kurella Janardhan
Swathik Kurella Janardhan 2016년 8월 16일
As Miyuru K mentioned, using commands fopen, textscan, fclose you should be able to read the values in specific columns.
You can use 'formatSpec' and 'N' fields in textscan function to read the desired format for 1000 steps by replacing 'N' with 1000.
Refer to this documentation link that explains about the usage of textscan function.

카테고리

Help CenterFile Exchange에서 Low-Level File I/O에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by