From: John T on
Hey guys,
I'm attempting to read in two sets of data structured in the following way (snippet below). What I would like to do is read in these two similarly structured sets of data from text files, and compare them line by line.

What I am grappling with is the best way to firstly read the data in, and then how to handle it!

I suspect the answer lays somewhere in using textscan and dynamically named structs, but I either lack the experience or imagination to see a suitable way forward.

Any pointers would be much appreciated! The two sets of data have matching top level MODE titles, with really only the numeric data at the bottom most level being different (it's those numerical values I need to compare and decide if they're identical or differ).

Input file snippet:

The files follow a sort of flattened tree arrangement. The structure of the short sample below follows;

MODE xxxx > 'SomeTitle SomeInteger' > 'SomeSubTitle SomeInteger' > 'SomeSubTitle SomeInteger' > *Data as table here*

The full set has around 50 Modes, each with many up sections. The format of MODE SomeTitle, followed by a branch with TITLE SomeInteger follows throughout.

MODE SCANNED_PROFILE_ELT
TO_SIZE 0
SPEED 100
GROSS_MARGIN 125000
UFG_DEV -15
0 0 0
1000 199 1.2
2000 398 2.4
UFG_DEV -10
0 0 0
1000 199 1.2
2000 398 2.4
UFG_DEV -5
0 0 0
1000 202 1.2
2000 403 2.4
UFG_DEV 0
0 0 0
1000 205 1.2
2000 409 2.4
UFG_DEV +5
0 0 0
1000 206 1.2
2000 412 2.4
UFG_DEV +10
0 0 0
1000 208 1.2
2000 415 2.4
UFG_DEV +15
0 0 0
1000 213 1.3
2000 425 2.6
UFG_DEV +20
0 0 0
1000 218 1.4
2000 435 2.7
UFG_DEV +25
0 0 0
1000 223 1.4
2000 445 2.7
UFG_DEV +30
0 0 0
1000 228 1.4
2000 455 2.8
GROSS_MARGIN 135000
UFG_DEV -15
0 0 0
1000 216 1.4
2000 431 2.7
UFG_DEV -10
0 0 0
1000 216 1.4
2000 431 2.7
UFG_DEV -5
0 0 0
1000 218 1.4
2000 436 2.7
UFG_DEV 0
0 0 0
1000 221 1.4
2000 442 2.7
UFG_DEV +5
0 0 0
1000 224 1.4
2000 448 2.7
UFG_DEV +10
0 0 0
1000 227 1.4
2000 454 2.7
UFG_DEV +15
0 0 0
1000 232 1.5
2000 463 2.9
UFG_DEV +20
0 0 0
1000 237 1.5
2000 473 3.0
UFG_DEV +25
0 0 0
1000 242 1.5
2000 483 3.0
UFG_DEV +30
0 0 0
1000 246 1.6
2000 492 3.1
From: Rune Allnor on
On 1 Feb, 21:01, "John T" <cj_wal...(a)me.com> wrote:
> Hey guys,
> I'm attempting to read in two sets of data structured in the following way (snippet below). What I would like to do is read in these two similarly structured sets of data from text files, and compare them line by line.
>
> What I am grappling with is the best way to firstly read the data in, and then how to handle it!
>
> I suspect the answer lays somewhere in using textscan and dynamically named structs, but I either lack the experience or imagination to see a suitable way forward.

I think anyone trying to implement this kind of thing in
'raw' matlab is in for a hard time. Matlab has, as far as
I know, no data structure well-suited for tree searches,
which means one would have to either emulate a tree data
structure using arrays, or hard-code the tree in terms of
nested case/switch statements.

In a language that has support for tree data strucures the
task would still be large, but a couple of orders of magnitudes
smaller than what would be required with matlab.

That being said: One can, as I understand it, access the Java
platform from matlab. If so, there might be something available
from Java that migh ease the task.

Rune