Impulse Response of a piecewise function
Show older comments
Is it possible to take the impulse response of a piecewise function?
I am wanting to produce frequency and impulse responses for a plot with a roll off factor. My roll off factors have been defined as r1, r2, and r3 (being the ideal condition). I created a piecewise function to show the graph, but this shows it in the frequency domain.
When I use the ifft(ifftshift ) command to get the impulse response of my plot I get an error. Is there a way to make this work?
Note, the first half of my code works the way I want it to
%generate roll off plot
syms f
Pf1 = piecewise(abs(f)<(Rb/2)-fx1, 1, abs(f-Rb/2)<fx1, (1/2)*(1-sin(pi*((f-(Rb/2))/(2*fx1)))), abs(f)>(Rb/2)+fx1, 0);
Pf2 = piecewise(abs(f)<(Rb/2)-fx2, 1, abs(f-Rb/2)<fx2, (1/2)*(1-sin(pi*((f-(Rb/2))/(2*fx2)))), abs(f)>(Rb/2)+fx2, 0);
Pf3 = piecewise(abs(f)<(Rb/2)-fx3, 1, abs(f-Rb/2)<fx3, (1/2)*(1-sin(pi*((f-(Rb/2))/(2*fx3)))), abs(f)>(Rb/2)+fx3, 0);
figure
fplot(Pf1,'r')
axis([-5, 5, -5, 5]);
grid on
hold on
fplot(Pf2,'b')
hold on
fplot(Pf3,'k')
title('Frequency Response')
hold off
%Generate the impulse respnose
%Code up to this point works, error past this point
IR_Pf1 = ifft(ifftshift(Pf1));
IR_Pf2 = ifft(ifftshift(Pf2));
IR_Pf3 = ifft(ifftshift(Pf3));
figure
fplot(IR_Pf1,'r')
axis([-5, 5, -5, 5]);
grid on
hold on
fplot(IR_Pf2,'b')
hold on
fplot(IR_Pf3,'k')
title('Impulse Response')
hold off
Answers (1)
madhan ravi
on 11 Dec 2018
0 votes
ifft() requires numerical approach wheras you feed in symbolic values therefore you need to convert the variables using subs() and then double() to make it of class double.
1 Comment
Kaylyn Wessel
on 11 Dec 2018
Edited: Kaylyn Wessel
on 11 Dec 2018
Categories
Find more on Digital Filter Analysis 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!