View License

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

» Watch video

Highlights from
Load Labview Binary Data

Join the 15-year community celebration.

Play games and win prizes!

» Learn more

3.0
3.0 | 2 ratings Rate this file 6 Downloads (last 30 days) File Size: 2.17 KB File ID: #27195 Version: 1.2

Load Labview Binary Data

by

Jeremy Smith (view profile)

 

08 Apr 2010 (Updated )

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   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (9)
31 May 2016 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?

Comment only
08 Dec 2015 Elizabeth Jones

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

06 Aug 2015 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.

Comment only
11 Apr 2013 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...

28 Feb 2011 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.

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

Comment only
13 Apr 2010 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.

Comment only
12 Apr 2010 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.

Comment only
09 Apr 2010 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?

Comment only
Updates
08 Apr 2010 1.1

- Improved description, no code change

06 May 2010 1.2

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

Contact us