How to sweep a sinusoidal signal using the system transfer function?

5 次查看(过去 30 天)
I have a bandpass filter schematic. I also have the corresponding transfer function.
Is it possible to sweep a sinusoidal signal, say from 0.10 Hz to 100 Hz, using either the schematic or the transfer fucntion, or both?

回答(1 个)

Star Strider
Star Strider 2020-1-4
I am not certain what you want.
A Bode plot of a filter with those frequency limits is straightforward, with the freqs function (using an example from the documentation):
a = [1 0.4 1];
b = [0.2 0.3 1];
f = logspace(-3, 1, 150); % Define As Hz
w = f*2*pi; % Convert To rad/sec
h = freqs(b,a,w);
mag = abs(h);
phase = angle(h);
phasedeg = phase*180/pi;
figure
subplot(2,1,1)
loglog(w,mag)
grid on
xlabel('Frequency (rad/s)')
ylabel('Magnitude')
subplot(2,1,2)
semilogx(w,phasedeg)
grid on
xlabel('Frequency (rad/s)')
ylabel('Phase (degrees)')
To convert the frequency axis to Hz:
xt = get(subplot(2,1,1), 'XTick');
set(subplot(2,1,1), 'XTick',xt/(2*pi), 'XTickLabel', xt, 'XLim',[0.1 100]/(2*pi)) % Convert Frequency Axis To Hz
set(subplot(2,1,2), 'XTick',xt/(2*pi), 'XTickLabel', xt, 'XLim',[0.1 100]/(2*pi)) % Convert Frequency Axis To Hz
Use freqs for continuous-time filters, and freqz for discrete filters.
  4 个评论
James Lockhart
James Lockhart 2020-1-10
Star Strider:
I really appreicate your help. Your are pretty close to what I am looking for as follows.
  1. I have the transfer feuction of a LC passive bandpass filter.
  2. Now, I need the response of the filter with input of a random signal, or noise, or sweeping a sinusoid signal or a chirp signal.
  3. This what I don't know how to do in Matlab.
Thankd a lot
Star Strider
Star Strider 2020-1-10
I already did the equivalent of that. I am not certain what you want.
I would just do this:
a = [0.07 0 20.2];
b = 0.2;
freqz(b, a, 2^12, 100)
That is the equivalent of this:
t = linspace(0.0, 1, 2E+2);
L = numel(t);
Ts = t(2)-t(1);
Fs = 1/Ts;
Fn = Fs/2;
in = zeros(size(t));
in(fix(L/2)) = 1;
out = filter(b, a, in);
FTin = fft(in)/L;
FTout = fft(out)/L;
FTtf = FTout./FTin;
ref = max(abs(FTtf));
Fv = linspace(0, 1, fix(L/2)+1)*Fn;
Iv = 1:numel(Fv);
figure
subplot(3,1,1)
plot(Fv, abs(FTin(Iv))*2)
grid
subplot(3,1,2)
plot(Fv, abs(FTout(Iv))*2)
grid
subplot(3,1,3)
plot(Fv, 20*log10(abs(FTtf(Iv))/ref))
grid
and produces the same result. The ‘in’ signal is a single pulse at t=L/2. The last subplot (transfer function) is in dB. The others are linear.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 MATLAB 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by