How to convert my input data into frequency response.

1 view (last 30 days)
Dear Sir,
I have generated a Chirp signal to AO, and capture the output data by AI. (Loopback) After captured the data I want to do a frequency response measurement. I'm not sure whether this is correct way to do it. Also, for the transform function portion, H=freqs(num,den,w);I can not get a constant value. I would appreciate if someone can guide me on this. Thanks!
if true
% code
endGenerate Chirp Signal
%AO
ao=analogoutput('winsound',0);
chan=addchannel(ao,[1,2]);
duration=1;
SampleRate=8000;
set(ao,'SampleRate',SampleRate)
NumSamples = SampleRate*duration;
%chirp function
t = 0:1/8000:2;
y = chirp(t, 20, 1, 20000);
data=transpose(y);
putdata(ao,[data data])
semilogx(y);
%AI
ai=analoginput('winsound',0);
chan=addchannel(ai, [1,2]);
set(ai,'SampleRate',SampleRate);
set(ai,'SamplesPerTrigger',duration*SampleRate);
ai.ManualTriggerHwOn = 'Trigger';
set([ai,ao],'TriggerType','Manual');
start([ai ao]),
trigger([ai,ao]);
data2=getdata(ai);
% Convert data to transform function
np=1;
sys = tfest(data2,np)
num = 15.39;
den=[1 30.8];
%Plot the frequency Response
w=20:100:20000;
H=freqs(num,den,w);
bode(num,den)
if true
% code
end

Answers (0)

Community Treasure Hunt

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

Start Hunting!