How to sweep a sinusoidal signal using the system transfer function?
5 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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?
0 Kommentare
Antworten (1)
Star Strider
am 4 Jan. 2020
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 Kommentare
Star Strider
am 10 Jan. 2020
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.
Siehe auch
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!