필터 지우기
필터 지우기

How to evaluate dirac function in matlab?

조회 수: 22 (최근 30일)
Atta Oveisi
Atta Oveisi 2013년 5월 23일
I have this problem in matlab 2011a that I can not evaluate dirac function of higher order. In other words, the symbolic expression works well:
syms x;
diff(dirac(x),x)
ans =
dirac(x, 1)
However, it can not evaluate dirac(x, 1) when x is double:
>> dirac(1, 1)
??? Error using ==> dirac
Too many input arguments.
What should I do? Is there any code available ?
I can evaluate this in Maple but it is hard to believe that matlab doesn't prepared for this simple problem.

답변 (2개)

Iman Ansari
Iman Ansari 2013년 5월 23일
편집: Iman Ansari 2013년 5월 23일
syms x;
y=diff(dirac(x),x)
subs(y,1)

Youssef  Khmou
Youssef Khmou 2013년 5월 23일
hi
The dirac function accepts only one argument (at least for earlier versions than yours) however, if you do not have the symbolic toolbox you can program your own function and put "1" in "0" instead of +infinity .
-First solution :
t=-10:0.001:10;
y=dirac(t);
figure, plot(t,y);
dy=diff(y)./diff(t);
figure, plot(t(1:end-1),dy,'r')
-Second solution :
function z=Dirac(t)
N=length(t);
z=zeros(size(t));
for n=1:N
if t(n)==0
z(n)=1;
end
end
Adjust this function for later use ....

카테고리

Help CenterFile Exchange에서 Special Functions에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by