MindBlast
JUB Addict
- Joined
- Jan 23, 2007
- Posts
- 1,225
- Reaction score
- 1
- Points
- 0
If so, I need some help.
I'm reading in a binary file (an XTF file actually), and I'm looking to store the data blocks in a structure array. The problem is that the structure array is "growing" every time the loop executes, and we all know how bad it is to grow arrays. I need to pre-initialize this thing, but how? Here's what I have and what I want:
The file is written like this, in binary:
fileheader with channelInfo as a substructure.
pingHeader. (this is the sonar data, it comes in pings or traces, there are 34801 of these in the particular file I'm looking at, but other files could have any number)
pingchannelHeader1 (it's a 2-channel system, there's one of these for each channel)
pingNdata1 (first channel data for the n-th ping)
pingchannelHeader2
pingNdata2 (second channel data for the n-th ping)
I've managed to extract all the header information, and then I loop going through to extract the ping header info from each ping, plus the data. I'm storing the data in a structure array called DATA.
The DATA structure array is eventually supposed to have 34801 (or however many there are) pings in it PER channel, so 2*34801. Each ping is 500 bytes long. I store the ping data in a 500 x 2 matrix (500 rows, 2 columns).
So the DATA structure looks like:
Ping1, Ping2, Ping3, ...., PingN
where each Ping is [500 x 2].
I can reference or call any ping by going DATA{k}, where k>=0.
My problem is that I need to initialize this structure array so the loop doesn't put Ping1 in, then Ping 2, and so on and grow the array each time.
I've tried using various things with the struct command, but it's no hope.
Assume I know how many pings (traces) there are, because I do. It's in the file header so I can call that variable.
Any help is appreciated.
I'm reading in a binary file (an XTF file actually), and I'm looking to store the data blocks in a structure array. The problem is that the structure array is "growing" every time the loop executes, and we all know how bad it is to grow arrays. I need to pre-initialize this thing, but how? Here's what I have and what I want:
The file is written like this, in binary:
fileheader with channelInfo as a substructure.
pingHeader. (this is the sonar data, it comes in pings or traces, there are 34801 of these in the particular file I'm looking at, but other files could have any number)
pingchannelHeader1 (it's a 2-channel system, there's one of these for each channel)
pingNdata1 (first channel data for the n-th ping)
pingchannelHeader2
pingNdata2 (second channel data for the n-th ping)
I've managed to extract all the header information, and then I loop going through to extract the ping header info from each ping, plus the data. I'm storing the data in a structure array called DATA.
The DATA structure array is eventually supposed to have 34801 (or however many there are) pings in it PER channel, so 2*34801. Each ping is 500 bytes long. I store the ping data in a 500 x 2 matrix (500 rows, 2 columns).
So the DATA structure looks like:
Ping1, Ping2, Ping3, ...., PingN
where each Ping is [500 x 2].
I can reference or call any ping by going DATA{k}, where k>=0.
My problem is that I need to initialize this structure array so the loop doesn't put Ping1 in, then Ping 2, and so on and grow the array each time.
I've tried using various things with the struct command, but it's no hope.
Assume I know how many pings (traces) there are, because I do. It's in the file header so I can call that variable.
Any help is appreciated.










 ](*,)](/images/smilies/bang.gif)