creating variables or an array from a complex text files

1 回表示 (過去 30 日間)
fadzhi
fadzhi 2016 年 8 月 12 日
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 Center および File ExchangeString Parsing についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by