creating variables or an array from a complex text files
1 次查看(过去 30 天)
显示 更早的评论
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
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
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.
0 个评论
另请参阅
类别
在 Help Center 和 File 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!