why cannot I get the figure by ezplot?

Dear all,
I wrote a program to plot the inverse laplace transform of a function wks, matlab can calculate it fast. But it is always busy and cannot give me the figure. Please help me with the problem! Thank you very much! The following is my code.
syms s
expositive=(s+sqrt(s^2+1))^2;
exnegative=1/expositive;
zt=1/(2*s); z2=1/(2*s);
n2=(zt-z2*(expositive-exnegative)/2)/(zt+z2*(expositive-exnegative)/2);
wks=2*(1-exnegative)/(expositive-exnegative)*(exnegative^4+n2*exnegative^5)/(1+n2*exnegative^10);
wkt=ilaplace(sym('wks'));
display('calculation finished')
ezplot(wkt,[0,100])

Answers (2)

wkt = ilaplace(wks);
Otherwise the calculated wks value from the previous expression will not be used.

3 Comments

Thank you Walter! But if you try to do like that, error warnings are given. In fact, I did it like what you said before I add sym to wks to get rid of the warnings but matlab is always busy and cannot give me the figure. Any one any good idea for this problem?
The following are the warnings.
Error using inlineeval
Error in inline expression
Error in inline/feval (line 34) INLINE_OUT_ = inlineeval(INLINE_INPUTS_, INLINE_OBJ_.inputExpr, INLINE_OBJ_.expr);
Error in ezplotfeval (line 54) z = feval(f,x(1),y(1));
Error in ezplot>ezimplicit (line 256) u = ezplotfeval(f, X, Y);
Error in ezplot (line 154) hp = ezimplicit(cax, f{1}, vars, labels, args{:});
Error in sym/ezplot (line 58) h = ezplot(char(f),varargin{:});
Error in simulationdelta (line 10) ezplot(wkt,[0,100])
"Error in inline expression" is not very specific unfortunately.
When I ask Maple to ilaplace wks, it complains of a division by 0. The reason for that is not clear to me. It could be, though, that your expression is running in to the equivalent of that division by 0.
Your wks has a lot of sqrt(s^2+1) and thus is not a polynomial or rational function of polynomials. Maple only promises to be able to do the transform for polynomials or rational functions of polynomials, but does know some other selected cases as well. It appears that it is not able to handle your situation.
Thank you very much!

Sign in to comment.

Shuang
Shuang on 26 Jan 2012
I tried to add wks=simple(wks)and wkt=simple(wkt)into the program and use wkt=ilaplace(wks) instead of wkt=ilaplace(sym('wks')) thus I got the result from matlab wks =
(2*s^2 + 1)/(1024*s^12 + 3584*s^10 + 4672*s^8 + 2784*s^6 + 740*s^4 + 70*s^2 + 1)
wkt =
sum((r3*exp(r3*t))/(3072*r3^10 + 8960*r3^8 + 9344*r3^6 + 4176*r3^4 + 740*r3^2 + 35), r3 in RootOf(s3^12 + (7*s3^10)/2 + (73*s3^8)/16 + (87*s3^6)/32 + (185*s3^4)/256 + (35*s3^2)/512 + 1/1024, s3))/2 + sum(exp(r3*t)/(3072*r3^11 + 8960*r3^9 + 9344*r3^7 + 4176*r3^5 + 740*r3^3 + 35*r3), r3 in RootOf(s3^12 + (7*s3^10)/2 + (73*s3^8)/16 + (87*s3^6)/32 + (185*s3^4)/256 + (35*s3^2)/512 + 1/1024, s3))/4
But it still cannot give me the figure. The warning is like this Error using char Cell elements must be character arrays.
Error in ezplot (line 159) fmsg = char(f);
Error in sym/ezplot (line 58) h = ezplot(char(f),varargin{:});
Error in simulationdelta (line 12) ezplot(wkt,[0,100])

1 Comment

I confirm that the simplification is valid.
I do not know why the message about cell elements is produced.
As an experiment try
wtknF = matlabFunction(vpa(wkt));
t = linspace(0,100,250); %250 is number of points you want
plot(t, wtknF(t))

Sign in to comment.

Tags

No tags entered yet.

Asked:

on 26 Jan 2012

Community Treasure Hunt

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

Start Hunting!