File Exchange

image thumbnail

Load Labview Binary Data

version 1.2 (2.17 KB) by

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

12 Downloads

Updated

View License

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.

Comments and Ratings (9)

Behdad

Behdad (view profile)

I also get the same error (line 65, "Maximum variable size allowed by the program is exceeded." )
Does anybody know where the problem is and how to overcome the problem?

The script worked like a charm right out of the box. I'm using Matlab R2015b on Windows. Thanks!

Manny

Manny (view profile)

https://decibel.ni.com/content/docs/DOC-39038

Take a look at my findings on working with binary data b/w matlab and labview.

Felix

Felix (view profile)

same problem here, on line 65, "Maximum variable size allowed by the program is exceeded."
When I try to skip this preallocation, I get other errors....
The binary file I try to load isn't even that big...

Robert

Robert (view profile)

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.

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...

Jeremy Smith

Jeremy Smith (view profile)

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

Jeremy Smith

Jeremy Smith (view profile)

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

Shaun

Shaun (view profile)

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?

Updates

1.2

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

1.1

- Improved description, no code change

MATLAB Release
MATLAB 7.4 (R2007a)
Tags Add Tags

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video