Use regular expression to extract a matrix from a file
Show older comments
Dear all,
I've been trying to read a matrix from a (very confusing) file, as shown below.
I am using MATLAB R2017a and the textread function with '%f%f%f%f' to read the "$Nodes" to "$EndNodes" numbers, but I had no success. What is the correct mask format to read this file as I need? More precisely, I need to extract the matrix from [1 0 0 0] to [12 0.3939339828220179 0.6060660171779821 0] in this example.
$MeshFormat
2.2 0 8
$EndMeshFormat
$Nodes
24
1 0 0 0
2 1 0 0
3 1 1 0
4 0 1 0
5 0.35 0.5 0
6 0.65 0.5 0
7 0.5 0.35 0
8 0.5 0.65 0
9 0.3939339828220177 0.393933982822018 0
10 0.6060660171779819 0.3939339828220176 0
11 0.6060660171779821 0.6060660171779821 0
12 0.3939339828220179 0.6060660171779821 0
$EndNodes
$Elements
46
1 1 2 3 1 1 2
2 1 2 4 2 2 3
3 1 2 5 3 3 4
4 1 2 4 4 4 1
5 2 2 1 1 6 20 17
6 2 2 1 1 7 15 13
7 2 2 1 1 9 14 15
$EndElements
Accepted Answer
More Answers (0)
Categories
Find more on Hypothesis Tests in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!