KroneckerDelta in matlab

前端 未结 4 1895
心在旅途
心在旅途 2021-01-21 02:01

This link shows that there is a kronecker delta function in matlab. However:

>> help kroneckerDelta

    kroneckerDelta not found

I am u

4条回答
  •  爱一瞬间的悲伤
    2021-01-21 02:12

    Your link to is to the MuPAD function kroneckerDelta -note the URL and the funky typography of the examples. You won't see it in any version of Matlab because it's only available through MuPAD (type mupad in your command window and try in the window that launches). I have no idea when it was added to MuPAD, I know that it's at least in R2012b. You may have it even if the help command returns nothing.

    If you have kroneckerDelta in R2011b, you won't be able to run it from the regular command window or Editor in the normal fashion.

    evalin(symengine,'kroneckerDelta(1,1)')
    

    or the more flexible

    feval(symengine,'kroneckerDelta',1,1)
    

    See more here. However, if you're not working with symbolic math, there's really no reason to use this function that I can see -it's not even vectorized! I'd go with a solution that fully emulates kroneckerDelta's behavior in double precision:

    function d=kronDel(m,n)
    if nargin == 1
        d = double(m==0);
    else
        d = double(m==n);
    end
    

提交回复
热议问题