MATLAB Answers

0

read .txt file data with data between specific lines "string" .

Asked by jahanzaib ahmad on 27 Jun 2019
Latest activity Commented on by Star Strider
on 27 Jun 2019
I want to read data between ( strings ) line starting from " *Node " and
ending at and next (strings ) line " *Element, type=C3D4" .

  0 Comments

Sign in to comment.

Tags

1 Answer

Answer by Star Strider
on 27 Jun 2019
 Accepted Answer

The textscan function using a numeric format descriptor string will automatically stop when it encounters:
*Element, type=C3D4
so this is actually a straightforward problem:
fidi = fopen('Copy_of_Job-1.txt','rt');
D = textscan(fidi, '%f%f%f%f', 'HeaderLines',9, 'Delimiter',',', 'CollectOutput',1);
fclose(fidi);
with ‘D’ being a (1418x4) double matrix.

  7 Comments

I am not certain what you are asking. I believe the code I posted in my Comment will do what you want.
If your file format remains the same, my code will work with all your files.
thankyou . i got it .. . ur code works perfectly
As always, my pleasure.
I appreciate your compliment.

Sign in to comment.