Code covered by the BSD License  

Highlights from
Load Labview Binary Data

Be the first to rate this file! 19 Downloads (last 30 days) File Size: 2.17 KB File ID: #27195

Load Labview Binary Data

by Jeremy Smith

 

08 Apr 2010 (Updated 06 May 2010)

labviewload.m loads in binary data files output by Labview.

| Watch this File

File Information
Description

This script loads Labview binary data files into Matlab. I only tested double precision and boolean data files but I'm sure it'll work on any other numeric type given the appropriate precision input into the labviewload.m script. I tested it up to a three dimensional double array but there is no limitation in the code which limits it to only three dimensions.

It can load data files which have been repeatedly written to as long as each array is the same size. It's an extremely simple script (46 lines minus the help info) so it's easy to modify for more complex Labview binary files.

Example usage:
     D = labviewload('BinaryData.bin',3); % Load a binary file consisting of a three dimensional double array

    D = labviewload('BooleanData.bin',1,'int8'); % Load a binary file consisting of a one dimensional boolean array

Keep in mind that the second input is the NUMBER of dimensions of the array within the binary file and not the actual dimensions.

It outputs a cell array of arrays. For one and two dimensional arrays you can simply use cell2mat to convert it into an even more convenient format.

Tested on Matlab R2007a and Labview 8.2.

MATLAB release MATLAB 7.4 (R2007a)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (5)
09 Apr 2010 Shaun

From the MatLab help:
A = fread(fileID, sizeA) reads sizeA elements into A and positions the file pointer after the last element read. sizeA can be an integer, or can have the form [m,n].

Why can't you accomplish this with one call to FREAD, then appropriate reshaping?

12 Apr 2010 Jeremy Smith

Habit and ignorance. I wasn't aware fread could do that. I'll update the script next chance I get.

13 Apr 2010 Jeremy Smith

Unfortunately fread cannot accept more than two dimensions so it will not work to use that method for data with higher dimensions.

20 Feb 2011 Kevin Dean

Thanks for developing the script. Still having a hard time getting it to work on my labview data. Keep getting the following error:

>> D=labviewload('PeakAmplitudes.bin',2,'uint32');
??? Error using ==> ones
Maximum variable size allowed by the program is exceeded.

Error in ==> labviewload at 65
data = repmat({NaN*ones(dims)},I,1); % Preallocate space, assumes each section is the same

Thanks in advance...

28 Feb 2011 Robert

I can confirm what Kevin says, I am getting the same error:

??? Error using ==> ones
Maximum variable size allowed by the program is exceeded.

Error in ==> labviewload at 65
data = repmat({NaN*ones(dims)},I,1); % Preallocate space, assumes each section is the same

Error in ==> data_processing at 7
data = labviewload('c:\110228103116StabTests.bin',8)

Please advice.

Please login to add a comment or rating.
Updates
08 Apr 2010

- Improved description, no code change

06 May 2010

- ~13 times faster on a test file after adding preallocation
- Fixed reshaping

Tag Activity for this File
Tag Applied By Date/Time
labview Jeremy Smith 08 Apr 2010 12:05:22
binary Jeremy Smith 08 Apr 2010 12:05:23

Contact us at files@mathworks.com