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

1 view (last 30 days)
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?

Accepted Answer

Mathieu NOE
Mathieu NOE on 2 Jan 2021
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 Comments
Mathieu NOE
Mathieu NOE on 4 Jan 2021
see
% [Gxy, f] = cpsd(xb(1:T*fs),y(1:T*fs), hanning(T2*fs),T2*fs/2, T1*fs, fs); % ? error here : ya instead of y ?
I corrected it

Sign in to comment.

More Answers (0)

Categories

Find more on Environment and Settings 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!