How to plot dirac n-th derivation ?
이 질문을 팔로우합니다.
- 팔로우하는 게시물 피드에서 업데이트를 확인할 수 있습니다.
- 정보 수신 기본 설정에 따라 이메일을 받을 수 있습니다.
오류 발생
페이지가 변경되었기 때문에 동작을 완료할 수 없습니다. 업데이트된 상태를 보려면 페이지를 다시 불러오십시오.
이전 댓글 표시
0 개 추천
I dont know how to plot this function which contains first and second derivation of dirac.
This is how i tried to solve it
Y= 80.624*t + 731939*dirac(t) + 6.373*(t^2) + 4663650*dirac(t,1) + 159*dirac(t,2) + 124126*(t^3);
ezplot(Y ,[0 1])
But Matlab send me:
Error using sym/dirac
Too many input arguments
Can someone please help. Thanks
채택된 답변
Star Strider
2015년 8월 31일
0 개 추천
You have the arguments to dirac reversed.
From the documentation:
- dirac(n,x) represents the n-th derivative of the Dirac delta function at x.
댓글 수: 36
joejonson
2015년 8월 31일
Thanks you for the answer.
That is what confusing me, beacuse i get this as answer when finding inverse Laplace of some another function. Do you know maybe how can i plot this ?
This works for me:
syms t
Y= 80.624*t + 731939*dirac(t) + 6.373*(t^2) + 4663650*dirac(1,t) + 159*dirac(2,t) + 124126*(t^3);
figure(1)
ezplot(Y ,[0 1])
I suggest you send the code that created your original ‘Y’ to MathWorks as a bug report. The Symbolic Math Toolbox should be producing consistent code. It is quite possible that you’re the first to discover this problem. Also, include the URL of this post, http://www.mathworks.com/matlabcentral/answers/238437-how-to-plot-dirac-n-th-derivation, to give it a context.
joejonson
2015년 8월 31일
It still doesn't work to me, but thanks you very much for helping.
Walter Roberson
2015년 8월 31일
joejonson, which MATLAB version are you using?
Matlab R2012b ,why are you asking Walter ?
The MuPAD version of dirac() has the derivative number after the expression but the interface that the Symbolic Toolkit provides from MATLAB to call MuPAD has the derivative number before the expression. If you attempted to use MuPAD code directly in MATLAB then the arguments would be in the wrong order.
The present order has been used at the MATLAB level since R2007b when MuPAD replaced Maple as the symbolic engine.
Could you check which version of dirac you are invoking?
which -all dirac
F:\Program Files\MATLAB\R2012b\toolbox\symbolic\symbolic\dirac.m
F:\Program Files\MATLAB\R2012b\toolbox\symbolic\symbolic\@sym\sym.m % sym method
Is that it ?
That does look appropriate.
If you use Star Strider's code,
syms t
Y = 80.624*t + 731939*dirac(t) + 6.373*(t^2) + 4663650*dirac(1,t) + 159*dirac(2,t) + 124126*(t^3);
then do you get the error at that point, or do you get the error when ezplot is processing it? If you use
subs(Y, t, 5.4321)
does that trigger the error? If not then does double() of the result trigger the error ?
Error occurs beacuse these two dirac (dirac(1,t) + dirac(2,t)) in both case. Subs also trigger error.
As an experiment, try
syms t
Y = 80.624*t + 731939*dirac(t) + 6.373*(t^2) + 4663650*diff(dirac(t,t) + 159*diff(dirac(t),t,t) + 124126*(t^3)
what does it return?
joejonson
2015년 8월 31일
Error using sym/dirac
Too many input arguments.
Error in dsdsa (line 2)
Y = 80.624*t + 731939*dirac(t) + 6.373*(t^2) + 4663650*diff(dirac(t,t)) + 159*diff(dirac(t),t,t) + 124126*(t^3)
Correction,
syms t
Y = 80.624*t + 731939*dirac(t) + 6.373*(t^2) + 4663650*diff(dirac(t),t) + 159*diff(dirac(t),t,t) + 124126*(t^3)
joejonson
2015년 8월 31일
There is no error now.
This is what I got.
(10078*t)/125 + 731939*dirac(t) + (6373*t^2)/1000 + 124126*t^3 + 4663809*dirac(t, 1)
I do not know why I didn't find it before, but according to the release notes, the two-input form of dirac is new as of R2014b.
Are you able to ezplot() the version that uses dirac(t,1) ?
It appears that it is treating dirac(t,2) as being equal to dirac(t,1) which does not appear to be correct.
I would be interested to see the result of
evalin(symengine, '80.624*t + 731939*dirac(t) + 6.373*(t^2) + 4663650*diff(dirac(t),t) + 159*diff(dirac(t),t,t) + 124126*(t^3)')
and
evalin(symengine, '80.624*t + 731939*dirac(t) + 6.373*(t^2) + 4663650*dirac(t,1) + 159*dirac(t,2) + 124126*(t^3)')
joejonson
2015년 8월 31일
Answer is the same:
80.624*t + 731939*dirac(t) + 6.373*t^2 + 124126*t^3 + 4663650*dirac(t, 1) + 159*dirac(t, 2)
Okay, so the workaround is this:
dirac = @(varargin) feval(symengine, 'dirac', varargin{:})
However, I have a suspicion you might be encountering https://www.mathworks.com/support/bugreports/details/571941 or https://www.mathworks.com/support/bugreports/details/578535, both of which are marked as fixed as of R2010b. Both of them are about problems with simplifying expressions that contain derivatives of dirac. Perhaps the fix did not really "take". Try simplify() the output of one of the evalin() and see if the expression changes.
joejonson
2015년 8월 31일
Expression is changed, but dirac functions are still the same.
Star Strider
2015년 9월 1일
Walter, Joe — I apologise for appearing to abandon this. I didn’t intentionally. Had to take a comatose laptop for repairs, an 85 km round-trip.
joejonson
2015년 9월 1일
It is OK, you dont have to apologise.
Do you maybe have some ideas how to help me with plotting.
I thought I did the plot. I don’t have access to R2012b. (This machine has Win 10 so I can’t install anything earlier that R2015a on it; the comatose computer has R2013a.)
With this code:
syms t
Y= 80.624*t + 731939*dirac(t) + 6.373*(t^2) + 4663650*dirac(1,t) + 159*dirac(2,t) + 124126*(t^3);
figure(1)
ezplot(Y ,[0 1])
This is the plot I get:

Can you please raise time, from 0 to 100,and show me picture. I am expecting some transient in this response,so i am curious.
Star Strider
2015년 9월 1일
I don’t see any transients:

Yeah, too bad. Is it problem if you tried it once more time,raising time up to 10000,just in case.. Thanks
Star Strider
2015년 9월 1일
My pleasure.
No real changes in the shape of the curve, and no transients. I also looked at ranges from 1E-3 to 1E+7.
joejonson
2015년 9월 1일
Star Strider and Walter Robertson - thanks you very much for everything, both of you really helped me out.
I hope i didnt bother much.
Thanks again!
Star Strider
2015년 9월 1일
My (our) pleasure. Walter — thanks for picking this up and exploring it while I was out running errands. (Life intrudes.)
No bother, but if you want us to see what you did with your dynamical system to get the result you did, describe it and post your code. No promises, but we might be able to help with it. If you expect transients, something went wrong somewhere. (If I remember correctly, the delta function should integrate to a constant.)
This is how my code looks like:
syms s t;
Rb=0.043;
Ra=1.071;
La=6.824;
Lb=0.272;
M=1.36;
C=0.000398;
i1=(200*((Rb + s*Lb + 1/(C*s))/((s^3)*(La*Lb*M - M^2)) + (s^2)*(Ra*Lb*M + La*Rb*M) + s*(M*Ra*Rb + La*M/C) + M*Ra/C));
F=ilaplace(i1);
pretty (F)
ezplot(F ,[0 1])
ylabel('I [A]')
xlabel('t [s]')
Star Strider
2015년 9월 1일
How did you get i1?
Is it a circuit analysis problem? If so, what does the circuit look like?
joejonson
2015년 9월 1일
It is circuit analysis.This is how it looks like:

There is no much parameters,just transformers primary and secundary resistance (Ra,Rb) and inductance(La,Lb) ,mutual inductance (M) and capacity (C).DC voltage is 200 V (step function).
I get i1 analizing this circuit in Laplace domain (two equations with two unknowns)
joejonson
2015년 9월 1일
This are the first two equations:

From second equation I excrete I2, and then put it in first equation.
I wrote the code in a simpler format and now everything is OK. I now got this :

This is something that I was expecting, beacuse at previuos pictures current goes to infinetly, so i was thinking that it will on some point start decreasing to zero,but that does not happend. The problem was created when i want to make final equation simpler, but actually I made it much complicated, and somewhere probably made mistake on multiplying.
Star Strider
2015년 9월 1일
I’m getting similar results (no transients) with my independent analysis. I can’t find the error. It most likely has to do with my not having done anything with transformers in a very long time.
The Laplace transform of the delta function is 1, and the step is 1/s, and since these are mutliplied by the transfer function, they shouldn’t show up as separate entities in the result.
joejonson
2015년 9월 1일
I think it is OK now. I was expecting some transient only beacuse current was raising to infinitely. That was strange to me, so I was thinking it will maybe at some point stop raising,and start decreasing to zero. These new results are looking much better.
Star Strider
2015년 9월 1일
What you’re getting now is what I would expect. The capacitor charges and the current eventually goes to zero in the secondary circuit. I got similar results.
joejonson
2015년 9월 1일
I am very grateful to both of you, Star Strider and Walter, for your time and all you have done to help me.! I appreciate it!
Thanks you again
Star Strider
2015년 9월 1일
My (our) pleasure!
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Common Operations에 대해 자세히 알아보기
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 MathWorks 사이트 방문이 최적화되지 않았습니다.
미주
- América Latina (Español)
- Canada (English)
- United States (English)
유럽
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
