Dirac function and matlabFunction
9 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Réponses (4)
Carlos
le 3 Avr 2014
Modifié(e) : Carlos
le 3 Avr 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 commentaires
Azzi Abdelmalek
le 3 Avr 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 commentaires
Walter Roberson
le 4 Avr 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 commentaires
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!