How to evaluate dirac function for Infi
2 views (last 30 days)
Show older comments
Elijah Kornefel
on 5 Mar 2019
Commented: Elijah Kornefel
on 5 Mar 2019
dk= 1;
k = -10:dk:10;
G=(dirac(k+8)-2*dirac(k+4)+dirac(k)-2*dirac(k-4)+dirac(k-8)).*exp(-1i*pi.*k/8);
idx = G == Inf; %find Inf
G(idx) = 1; %sets Inf = 1
mag=abs(G);
stem(k,mag)
title('Magnitude vs k')
xlabel('k')
ylabel('Magnitude')
figure
phase=angle(G);
stem(k,phase)
title('Phase vs. k')
xlabel('k')
ylabel('Phase')
I know how to show values when G is equal to Inf, but my issue rises when G = Inf + Infi for example.
I have tried:
idi = G == -Inf + Infi;
G(idi) = 1i;
But no luck. Any help appreciated.
0 Comments
Accepted Answer
Walter Roberson
on 5 Mar 2019
idi = G == complex(-inf, inf);
G(idi) = 1i;
3 Comments
Walter Roberson
on 5 Mar 2019
Could you confirm that your system cannot produce +inf +inf*i ?
You can make the code more compact:
notfin = ~isfinite(G);
G(notfin) = complex(sign(real(G(notfin))), sign(imag(G(notfin))));
More Answers (0)
See Also
Categories
Find more on Introduction to Installation and Licensing 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!