View License

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

» Watch video

Highlights from
UFF File Reading and Writing

4.7 | 20 ratings Rate this file 64 Downloads (last 30 days) File Size: 134 KB File ID: #6395 Version: 1.22
image thumbnail

UFF File Reading and Writing


Primoz Cermelj (view profile)


26 Nov 2004 (Updated )

Reading and writing of ascii files in Universal File Format (UFF).

| Watch this File

File Information

UFF bundle contains 2 functions, one for reading (readuff) and one for writing (writeuff) of ascii and binary files in Universal File Format (UFF). Although there are many different data-sets that can be stored in UFF files in general, only data-sets
151, 15, 18, 55, 1858, 58, 82, 164, 2411, 2420, and also the hybrid one, 58b, are supported.


This file inspired Bruel & Kjaer Pulse Labshop Measurement Organizer Exporter.

MATLAB release MATLAB 7 (R14)
MATLAB Search Path
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (29)
25 Mar 2016 Vinnydp

I tried test_uff.m whit this file generated by LMS Test.Lab

Harmonic Spectrum for A0001X:+X
22-Mar-16 09:27:40
Record 1 of section "MM_SQLX1", run "SineRed_7"
Sweep 1
12 0 0 0 A0001X 1 1 A0001X 1 1
5 973 0 0.00000e+00 0.00000e+00 0.00000e+00
18 0 0 0 X-axis Hz
12 0 0 0 120 g
0 0 0 0 NONE NONE
0 0 0 0 NONE NONE
5.00000e+00 6.32878e-01 -6.10272e-02 5.02111e+00 6.57713e-01 -6.88457e-02
5.03501e+00 6.80860e-01 -6.70124e-02 5.09096e+00 7.17241e-01 -6.78049e-02


The original file is in the form:

Frequency Real Immaginary

The problem is that the file I obtain in output is quite different.
This is the results.

Harmonic Spectrum for A0001X:+X
22-Mar-16 09:27:40
Record 1 of section "MM_SQLX1", run "SineRed_7"
Sweep 1
12 0 0 0 A0001X 1 1 A0001X 1 1
6 973 1 5.00000e+00 2.11100e-02 0.00000e+00
18 0 0 0 NONE Hz
12 0 0 0 NONE g
13 0 0 0 NONE NONE
0 0 0 0 NONE NONE
6.32878000000e-01 -6.10272000000e-02 6.57713000000e-01 -6.88457000000e-02


In the form:

Real Immaginary (equispaced in frequency)

this is the matlab code i used:

% Test for reading and writing of UFF files.

% First, let's read all the data-sets from the dam0.unv file

[DS, Info, errmsg] = readuff('dam0.unv');
writeuff('dam0_out.unv', DS, 'replace');

only read and write the result file should be the same of the original.

Can someone help me?

Thanks in advance,

21 Dec 2015 Grzegorz

19 Nov 2015 David Alpert

I am working with writeUFF (the 14 Nov 2015 version) and I found a couple bugs.

The first bug is with uneven spacing in the abscissa. I made a MWE to write an FRF at frequencies [11,20,30]. The resultant UFF has a 58 card with even spacing starting at 11 and increment of 9 instead of the appropriate uneven spacing.

The second bug I found is when I was mixing complex and real FRFs. I am exporting 2 FRFs, one is all real ordinates and the other is complex ordinates. I need all the 58 cards to have complex ordinates. Is there a way to make writeUFF consistently output all complex ordinates even if some are real? I did try using MATLAB's complex function on the real ordinates prior to writeUFF but it still produces a 58 card with real ordinates.

Thanks for your help.

Comment only
14 Nov 2014 Lehtym

Lehtym (view profile)

There is a bug in reading dataset 58b.
If first byte of binary block corresponds to newline character it is skipped and block is considered to have incorrect length. Consider the following fix.

1) introduce
ind_bb1 = blockLines(11,2) + 3; % index of first byte of binary block

2) replace where appropriate blockLines(12,1) by ind_bb1

17 Jun 2014 John Anderson

I found that the binary uff 58 file read in and then written out from MATLAB could not be read into nCode or Head Acoustics Artemis. Problem appears to be in header section formatting. I can send you a screen shot of the comparison using gvim.

Comment only
27 May 2014 Grzegorz

12 Jul 2013 Jianliang Wang

there a field named "ordDenomDataChar" in the writeuff.m, but there is not a same field in the readuff.m
when I want to write a chaged uff structure, I should to added it.

Comment only
12 Jul 2013 Jianliang Wang

27 May 2013 Primoz Cermelj

Primoz Cermelj (view profile)

Fixed the issue Ozan pointed out, i.e., using numpt.

Comment only
26 Apr 2013 Ozan Oguz

There is a mistake in the extract58 data reading, which causes wrong plotting.

Instead of using "end-1" and "end" values to fill "measdata" and "x" values (((i.e. UFF.x = values(1:2:end-1);))), you should use "numpt" which is defined already as the number of measured data points.

This is neccessary in some uff recordings, as there are extra "zero" values at the end of the recorded data, which are not real measured data and used only to complete the columns and lines of UFF or UNV recording. Using "end" causes you to have these false data points.

See this:

% Abscissa and ordinate values
if (ordDataType == 2 || ordDataType == 4)

% non-complex ordinate data
if spacingType == 0 % uneven abscissa
UFF.x = values(1:2:end-1);
UFF.measData = values(2:2:end);
else % even abscissa
UFF.measData = values;
nVal = length(UFF.measData);
UFF.x = UFF.xmin : UFF.dx : UFF.xmin + (nVal-1)*UFF.dx;
elseif (ordDataType == 5 || ordDataType == 6)

% complex ordinate data
if spacingType == 0 % uneven abscissa
UFF.measData = values(2:3:end-1) + j*values(3:3:end);
UFF.x = values(1:3:end-2);
else % even abscissa
UFF.measData = values(1:2:end-1) + j*values(2:2:end);
nVal = length(UFF.measData);
UFF.x = UFF.xmin : UFF.dx : UFF.xmin + (nVal-1)*UFF.dx;
errMessage = ['error reading measurement data at:' num2str(lineN)];


Comment only
22 Mar 2013 Ozan Oguz


I am trying to read a UFF58 data. I can only plot the "data description" part, but couldn't manage to plot the measurment data.

Can you give a hint please? Is it possible at all?

Thank you!

Comment only
26 Feb 2013 AlexG

AlexG (view profile)

Great program, thanks.

it does not work to read a certain data type only with readuff.m . Please consider replacing:
if ~find(dsTypes==data_set_type)
if dsTypes~=data_set_type

And moving:
dataSetN = dataSetN + 1;
just before:
UffDataSets{dataSetN} = ds_data;


08 May 2011 ehs

ehs (view profile)

15 Mar 2011 oddo

oddo (view profile)

I have found an excel sheet for reading uff file here :

Comment only
04 Jan 2011 Jake Zwart

I had problems reading binary data into Ideas, so added single precision write capability and now it works.

21 May 2009 Tom Cunningham

If I ever get to Europe, you pick the spot and I'll buy dinner! And if you ever get to Pittsburgh, I know where to eat and I'm still buying. Thanks again for a very useful program! It is the cornerstone of my vibration post-processing GUI.

Comment only
18 Jul 2008 Ryan Edwards

Thank you for this function. You also saved me a lot of work. As much as I would enjoy writing a function to read uff files, I just didn't have the time for this particular task I was working. Thanks again.

04 Jan 2008 Seshagiri Rao Maddipati

Very cool. U saved me lot of work. Thank you so much. now i can transfer data from Onosokki to CADA-X through matlab

19 Oct 2007 Miguel Colomo

I used it to read UFF data and create data from Matlab to CADA-X /LMS software. It was incredibly useful

13 Jun 2007 Ryan Dolan

Wow... I am in your debt. You just saved me a ton of work.

04 May 2007 John Anderson

I tried it on a .unv file output from LMS Virtual.Lab with results from a modal test (format 55). It works fine. This just saved me at least a day to write my own. Very cool!

25 Apr 2007 Helene Illaire

Worked fine on Universal ascii 58 type of data (imported from Cada-X LMS).

15 Feb 2007 Thomas Cunningham

Using ver. 0.9.9b2, I have read 58b data embedded in a proprietary file format that was actually a universal file with added data- this reader still managed to extract the data, so I'm not sure what your problem might be. I stand by my 5 stars for now, good luck!

Comment only
25 Jan 2007 Yiu Luk

I don't seem to be able to read Universal binary 58b type of data. The ASCII part seems OK.

05 Jun 2006 Thomas Cunningham

Worked wonderfully on IOTech's Zonicbook 618 universal files. I embedded it in a calling function & graphed reams of spectra in minutes. Good work!

10 Jun 2005 scott reilly

our instrument (polytec laser) kicked out a file that had invisible carriage returns in the windows environment. these had to be stripped out of the data file so that this m file could read the data.

21 Apr 2005 Frantz JOURDA

Exactly what I was looking for. Tanks you Primoz, you're a star !

15 Feb 2005 Ray Martell

Nice of the better ascii uff writers/readers i've seen.

14 Feb 2005 Matt Allen

Great program. Thanks!

01 Dec 2004

Update; full m-code available

17 Jan 2005

Update (speed improvement)

20 Jan 2005

minor update

04 Mar 2005

164 data-set related bug removed

23 May 2005


20 Jun 2005

Update: the hybrid (ascii-binary) format 58b is now supported; some minor changes to remove some bugs

26 Jan 2006

Update; uneven abscisa data can be read/written

30 Jan 2006

Minor bug removed (even abscisa-values field was twice as long as it should be when reading 58 data-set)

06 Jun 2006

able to read only a portion of the unv file

03 Aug 2006


04 Aug 2006

another fix for 58b data-set

09 Jan 2008


11 Mar 2008

datasets 2411 and 2412 added to readuff

11 Mar 2008

Description update

13 Mar 2008

a minor bug fixed

09 Nov 2008 1.1

minor update

20 May 2009 1.2

license update

20 Jun 2009 1.3

License update

17 Jul 2009 1.5

license change

11 Apr 2010 1.6

Minor fix

20 Jul 2010 1.7

1858 data-set added to writeuff

30 Aug 2010 1.8

Minor fixes

30 Aug 2010 1.9


23 Feb 2011 1.10

Description changed

18 Jul 2012 1.12

Minor fixes

27 Feb 2013 1.14

Minor fixes

27 Feb 2013 1.15


28 May 2013 1.16

Minor fix in readuff

24 Nov 2014 1.17

Fixed bug when writing data-set 55 (dataType not taken into account properly in special cases).

14 Nov 2015 1.20

dataset 18 reading and writing support added

20 Nov 2015 1.21

A bug fixed in writeuff.

02 Dec 2015 1.22

Minor fix

Contact us