Dirac function and matlabFunction
7 views (last 30 days)
Show older comments
hello!
I'm having problems evaluating a matlab function that has dirac within. I have the following symbolic function: mf = v^2*dirac(x + 0.5) + 3*v^2*dirac(x + 0.5, 1)
I then created a matlab function by doing this: ht = matlabFunction(mf)
ht = @(v,x)(v.^2.*dirac(x + 0.5) + 3.*.v.^2.*dirac(x + 0.5, 1))
Everything works well. But when I then try to evaluate the function by doing this:
ht(2, 7)
I get an error. It says "Error using dirac. Too many input arguments." How do I evaluate that function correctly?
thanks in advance!
0 Comments
Answers (4)
Carlos
on 3 Apr 2014
Edited: Carlos
on 3 Apr 2014
The problem is this line of the code dirac(x + 0.5, 1), dirac only allows one argument. Why do you include the second parameter 1? What do you want to represent? Just a dirac function centered in -0.5? then just write dirac(x + 0.5) as in the previous command
0 Comments
Azzi Abdelmalek
on 3 Apr 2014
In your expression what is dirac(x+0.5,1)? it should be dirac(x+0.5)
ht = @(v,x)(v.^2.*dirac(x + 0.5) + 3*v.^2.*dirac(x + 0.5))
ht(2,7)
0 Comments
Walter Roberson
on 4 Apr 2014
Please show the z formula for which mf is the derivative.
It appears to me that your z most likely contains dirac and not heaviside and that dirac(x + 0.5,1) is an attempt to represent the first derivative of the dirac function.
Which MATLAB version are you using? Are you possibly using Maple as your symbolic engine instead of MuPAD ?
0 Comments
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!