# Evaluate the system impose response function and the FRF with given input and output data

조회 수: 5(최근 30일)
Christina Reid 2021년 1월 2일
댓글: Christina Reid 2021년 1월 4일
Hello!
I have the input and output data of a signal that is stored in a .mat file. I need help calulating the impulse response and the FRF. I have attached the .mat file. I know how to pull the info from the .mat file and the time length is 20 sec
data = importdata ('beam_experiment.mat');
x = transpose(data.x); %input
y = transpose(data.y); %output
fs = data.fs; % sampling frequency
T1 = 20;
I tried the follow:
data = iddata(y, x, 1/fs);
h = impulseest(data,2*max(time)*fs, min(time)*fs);
H = fft(h);
but get the following error message "Error using fft
Invalid data type. First argument must be double, single, int8, uint8, int16, uint16, int32,
uint32, or logical."
Could somone kindly help out?

댓글을 달려면 로그인하십시오.

### 채택된 답변

Mathieu NOE 2021년 1월 2일
HELLO
had to find another way than using the ID Toolbox (as I don't have it)
so I basically tried to fit an IIR model to the FRF and then you can create the impulse response
data = importdata ('beam_experiment.mat');
x = transpose(data.x); %input
y = transpose(data.y); %output
fs = data.fs; % sampling frequency
T1 = 20;
NFFT = 2048;
NOVERLAP = 0.75*NFFT;
[Txy,F] = tfestimate(x,y,hanning(NFFT),NOVERLAP,NFFT,fs);
% IIR model
W = linspace(0,pi,length(F));
ind = find(F>5 & F <80); % frequency weighting ; data reliable between 5 and 80 Hz
WT = zeros(size(W));
WT(ind) = 1;
NB = 6;
NA = NB+2;
[B,A] = invfreqz(Txy,W,NB,NA,WT,1e4);
% check bode plots
[H,WW] = freqz(B,A,length(F));
figure(1),
subplot(2,1,1),plot(F,20*log10(abs(Txy)),'b',F,20*log10(abs(H)),'r');grid
subplot(2,1,2),plot(F,180/pi*(angle(Txy)),'b',F,180/pi*(angle(H)),'r');grid
% Impulse response
[IR,X] = dimpulse(B,A);
samples = length(IR);
time = 1/fs*(1:samples);
figure(2),
plot(time,IR,'r');grid
title('Impulse response')
xlabel('Time (s)');
ylabel('Amplitude')
##### 댓글 수: 10표시숨기기 이전 댓글 수: 9
Christina Reid 2021년 1월 4일
aaaah! Bless your soul! I have been banging my head aganist the wall for this one!

댓글을 달려면 로그인하십시오.

### 범주

Find more on Short-Time Fourier Transform in Help Center and File Exchange

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by