You are now following this question
- You will see updates in your followed content feed.
- You may receive emails, depending on your communication preferences.
How to convert frequency response data from .unv file into time domain and save into another data file?
22 views (last 30 days)
Show older comments
I am trying to look into several data files I collected online about strucutral vibration of 8-DOF System. The files are saved as .unv and I found code online that is able to read the files ( from Read Uff ). However, when I tried to convert the frequency response data into time domain I get a complex double back. Is there a way I can get the response data as time domain becuase I think the response should be an impulse response and save the time response as, for example, .txt file?
Here is my code
%% Test File
% Test for reading and writing of UFF files.
close all; clear; clc
% First, let's read all the data-sets from the dam0.unv file
[DS, Info, errmsg] = readuff('----\jan298m1\jan298m1.unv');
% Let's check what is the first data-set like
DS{1}
y_f = DS{1}.measData
y_t = ifft(y_f)
3 Comments
dpb
on 2 Nov 2021
This all depends on what is actually in the file -- the description of the file data types at the link shows only one type that is a time response; all the frequency-related values are higher-level consolidations like PSDs.
None of those response functions contain the actual FFT of magnitude AND phase that is required to peform a unique IFFT() and return the input time history.
There are ways to generate representative time histories that will produce an equivalent PSD in the literature (mostly/all that I'm aware of are specifically designed for earthquake spectra, however).
Mohamed Mohamed Ahmed
on 2 Nov 2021
Edited: Mohamed Mohamed Ahmed
on 2 Nov 2021
Well, I found the report for the test and authors mentioned that each file contains the following: "Each file is a universal data file (type 58) containing the frequency response functions, input power spectral density, response power spectral densities, cross-power spectra and coherence functions. If multiple measurements were averaged, all spectral functions are the averaged quantities"
dpb
on 2 Nov 2021
Edited: dpb
on 2 Nov 2021
If they didn't save the time histories as well, nor the actual FFTs but only the above results, then the phase data have been thrown away and can't be retrieved.
I didn't try to examine the actual file content...the description implies they COULD be saved under the file format used, but none of the above is conclusive that they were--and, taken literally at face value that nothing else was saved, says they weren't.
Accepted Answer
Mathieu NOE
on 2 Nov 2021
hello
the time data are here :
% Test for reading and writing of UFF files.
close all; clear; clc
% First, let's read all the data-sets from the dam0.unv file
[DS, Info, errmsg] = readuff('jan298m1.unv');
% % Let's check what is the first data-set like
% DS{1}
% y_f = DS{1}.measData
% y_t = ifft(y_f)
% time data extraction (impulse response)
for ci = 1:9
figure(ci),
plot(DS{33+ci}.x,DS{33+ci}.measData)
end
25 Comments
Mohamed Mohamed Ahmed
on 2 Nov 2021
Thank you for the answer, I would like to know how did you get to the solution? Becuase when I was looking at the report, the authors metntioned the setup which is the following:
"the instrument set-up parameters are as follows unless noted in this column:
- Maximum frequency 200 Hz
- Number of frequency lines 1600
- Record length 8 sec
- Sample rate 500 Hz
- Number of data points 4096"
dpb
on 2 Nov 2021
As noted above, that says what they did about the spectral data and how were generated, but doesn't preclude that they also saved the input time histories.
Mathieu NOE
on 2 Nov 2021
hello
yes the infos you mentionned are relatedto the acquisition and FFT process
what is relevant for the time data is only the sampling frequency and Number of data points (Record length is a result of the combination of sampling freq and number of data points)
I also looked into the unv file itself to make sure the time data was stored , which may not always be the case, depending of vendors softwares configuration
Mohamed Mohamed Ahmed
on 2 Nov 2021
@Mathieu NOE Okay, how were you able to get the amplitude values from the complex values?
dpb
on 2 Nov 2021
Edited: dpb
on 2 Nov 2021
That's what @Mathieu NOE is telling you -- he didn't. He dove into the guts of the data file itself and actually pulled out the original time series data.
You simply CANNOT resurrect what has been lost from the frequency-based spectra stored here because in all of those, the phase information is lost.
If you look at his code, you'll see he's pulling those data from different indices..
Mathieu NOE
on 3 Nov 2021
well well
to be honest with you , yes , there are some time domain measurements , indeed there are 9 data available :
- first one is the excitation signal (looks like a hammer test)
- following 8 datas are the time responses
but as the excitation signal is not a pure impulse (dirac) , we cannot take the time responses as impulse response directly
instead , we have the complex FRF's (frequency response functions) data, where we can indeed compute the inverse FFT and get back the Impulse response
but the computation is slightly longer than simply doing ifft(FRF) as shown in the code below
also I double checked by computing back the FRF from that IR and double check with the measured FRF's
the code accounts for :
- measured FRF are one sidded , but ifft requires a double sided complex FRF
- FRF frequency axis is truncated to Fs/2.56 and not Fs/2 , so this must be taken into account when regenerating FRF from IR (I am using freqz)
code
% Test for reading and writing of UFF files.
close all; clear; clc
% First, let's read all the data-sets from the dam0.unv file
[DS, Info, errmsg] = readuff('jan298m1.unv');
% % Let's check what is the first data-set like
% DS{1}
% freq = DS{1}.x
% y_f = DS{1}.measData
% y_t = ifft(y_f)
%
% figure(1)
% subplot(211),plot(freq,20*log10(abs(y_f)));
% subplot(212),plot(freq,180/pi*(angle(y_f)));
dt = DS{42}.dx;
Fs = 1/dt
% FRF data extraction (and IR computation )
for ci = 1:8
freq = DS{ci}.x;
y_f = DS{ci}.measData;
N = length(y_f);
y_f_flipped = y_f(N-1:-1:2);
h = [y_f ; conj(y_f_flipped)];
y_t = ifft(h);
y_t = real(y_t(1:N));
time_ifft=[0:N-1]*dt;
% reconstruct FRF from IR (double check)
frf = freqz(y_t,1,freq,2*max(freq)); % here we need to consider sampling freq = 2 * max freq
% displayed in the measured FRF (this was truncated as Fs real = 512 Hz but FRF displayed only up to 200 Hz)
figure(ci),
subplot(311),plot(freq,20*log10(abs(y_f)),'b',freq,20*log10(abs(frf)),'--r');
xlabel('Frequency (Hz)');
ylabel('Amplitude (dB)');
title('FRF');
legend('measured','recomputed from IR');
subplot(312),plot(freq,180/pi*(angle(y_f)),'b',freq,180/pi*(angle(frf)),'--r');
xlabel('Frequency (Hz)');
ylabel('Phase (°)');
legend('measured','recomputed from IR');
subplot(313),plot(time_ifft,y_t);
xlabel('Time (s)');
ylabel('Amplitude');
title('Impulse response');
end
% % time data extraction (hammer impulse + 8 channels responses)
% for ci = 1:9
% figure(10+ci),
% plot(DS{33+ci}.x,DS{33+ci}.measData)
% end
%
plot for the 8th FRF

Mohamed Mohamed Ahmed
on 3 Nov 2021
Thanks for the detailed explanation, I have been trying to obtain the plot using ifft and getting the magnitude and phase of FRF and revert it back to time domain using ifft but I keep on having difficulties with the amplitude. But, I tried your code and I keep on having error occurring at
h = [y_f ; conj(y_f_flipped)];
due to inconsistency with length of array due to
y_f_flipped
have around 1599 length.
Mathieu NOE
on 3 Nov 2021
hello
my pleasure
FYI , the dimensions of the arrays when I run the code , are :
y_f 1601x1 25616 double array (complex)
y_f_flipped 1599x1 25584 double array (complex)
y_t 1601x1 12808 double array
h 3200x1 51200 double array (complex)
(NB : lenght of h = 3200 as concatenation of y_f and conj(y_f_flipped)
what is the situation on your side ?
Mohamed Mohamed Ahmed
on 3 Nov 2021
Here is my output:
* DS <1x42 cell>
* Fs 512.006
* N 1601
* Freq <1x1601 double>
* y_f <1x1601 complex double>
* y_f_flipped <1x1599 complex double>
The error is about using vertcat, Dimensions of matrices being concatenated are not consistent.
Mathieu NOE
on 3 Nov 2021
funny
so your arrays have same dimensions, but are transposed
try this , it should be good now
replace
h = [y_f ; conj(y_f_flipped)];
with
h = [y_f conj(y_f_flipped)];
Mohamed Mohamed Ahmed
on 3 Nov 2021
Yes, now it seems to work. One final question though, looking at figures, the recomputed seemed to follow the measured, but, in Figures 1 and 2, the measured and recomputed seems to shift from each other, is this where dpb was saying about the phase information being missing which caused this shift?
Mathieu NOE
on 3 Nov 2021
No, I see the problem but I work from the complex FRF data, so the phase is taken into account (and displayed too!) because y_f is complex , so phase is there ...
but I am not sure why the two first data sets show a bit more discrepancy in the lower frequency range... have to think about it
otherwise I a m pretty happy that it matches quite well
Mohamed Mohamed Ahmed
on 3 Nov 2021
Edited: Mohamed Mohamed Ahmed
on 3 Nov 2021
Okay. Thank you very much for your help, that’s all the questions I have at the moment. I appreciate it.
Kayhan
on 11 May 2023
I read your post, thank you for the brief explanation.
When I tried to open my FRF data, I am getting following error;
Error in read_uff (line 14)
dt = DS{42}.dx;
When I change this DS{2}.dx;
I can see some plots, however, I am getting following error still;
Index exceeds the number of array elements. Index must not exceed 2.
Error in read_uff (line 18)
freq = DS{ci}.x;
Could you help me with that?
Kayhan
on 12 May 2023
thank you for fast response.
you can find it in attachments.
I am wondering how can draw FRF datas without using readuff file?
Kind Regards,
Kayhan
Mathieu NOE
on 12 May 2023
why is using readuff a problem ?
here this uff file has only two freq domain data sets : FRF and COH
so you must adapt your m code accordingly :
% Test for reading and writing of UFF files.
close all; clear; clc
% First, let's read all the data-sets from the dam0.unv file
[DS, Info, errmsg] = readuff('FRF1.uff'); % this uff file has only two freq domain data sets : FRF and COH
% Let's check what is the first data-set like
freq = DS{1}.x;
FRF = DS{1}.measData;
coh = DS{2}.measData;
figure(1)
subplot(311),plot(freq,20*log10(abs(FRF)));
ylabel('Amplitude (dB)');
title('FRF');
subplot(312),plot(freq,180/pi*(angle(FRF)));
ylabel('phase (°)');
subplot(313),plot(freq,coh);
xlabel('Frequency (Hz)');
ylabel('coherence');
Fs = 2*max(freq);
dt = 1/Fs;
% FRF data extraction (and IR computation )
N = length(FRF);
FRF_flipped = FRF(N-1:-1:2);
h = [FRF ; conj(FRF_flipped)];
y_t = ifft(h);
y_t = real(y_t(1:N));
time_ifft=[0:N-1]*dt;
% reconstruct FRF from IR (double check)
frf = freqz(y_t,1,freq,Fs);
figure(2),
subplot(311),plot(freq,20*log10(abs(FRF)),'b',freq,20*log10(abs(frf)),'--r');
xlabel('Frequency (Hz)');
ylabel('Amplitude (dB)');
title('FRF');
legend('measured','recomputed from IR');
subplot(312),plot(freq,180/pi*(angle(FRF)),'b',freq,180/pi*(angle(frf)),'--r');
xlabel('Frequency (Hz)');
ylabel('Phase (°)');
legend('measured','recomputed from IR');
subplot(313),plot(time_ifft,y_t);
xlabel('Time (s)');
ylabel('Amplitude');
title('Impulse response');
Kayhan
on 12 May 2023
Thank you for quick response.
I'm having issue regarding to vector dimension as following;
Error using vertcat
Dimensions of arrays being concatenated are not consistent.
Error in read_uff (line 23)
h = [FRF ; conj(FRF_flipped)];
I guess it is because FRF file contains 1x1601 size while FRF_flipped contains 1x1599 size.
Readuff good tool to evaluate FRF data in UFF, however, I want to develop my own m code for this kind of applications.
Mathieu NOE
on 12 May 2023
hello
this line may be to change demepnding of the orientation of the data if they are row or column oriented
this line :
h = [FRF ; conj(FRF_flipped)];
must be changed into :
h = [FRF conj(FRF_flipped)];
and now it should work
not sure why you want to reinvent readuff (is it a home work assignment ?)
Kayhan
on 12 May 2023
Yeah, it worked now , thank you.
Not a homework assignment, just a curiosity how it could be developed.
Mathieu NOE
on 12 May 2023
well , uff and unv files are text files , but the format is not very simple !
you can try to make your own wrapper (for example with readlines) but if you look at how complex is readuff , it's going to take some efforts to make something robust !
Kayhan
on 20 May 2023
@Mathieu NOE hello, have you ever tried to plot mode shapes taken from circular plate FRF measurement? You can think like circular plate attached with sensors, I extracted all natural frequencies, damping ratios and mode shape vectors, however, unable to plot those in circular format.
Kayhan
on 22 May 2023
@Mathieu NOEt thank you for response. I am working on to plot mode shapes by extracted results in 3d due to geometry is circular plate.
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!An Error Occurred
Unable to complete the action because of changes made to the page. Reload the page to see its updated state.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom(English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)