Impulse Response of a piecewise function
Afficher commentaires plus anciens
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
Réponses (1)
madhan ravi
le 11 Déc 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 commentaire
Kaylyn Wessel
le 11 Déc 2018
Modifié(e) : Kaylyn Wessel
le 11 Déc 2018
Catégories
En savoir plus sur Digital Filter Analysis dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!