Error using plot Conversion to double from sym is not possible.

plot([0,2],[0,0],'k');
plot([0,0],[0,2],'k');
sol=dsolve('D3y-3*D2y+y=-3*x','y(0)=0','Dy(0)=3','D2y(0)=0','x');
xx = 0:0.1:2;
yy = subs(sol,'t',xx);
plot(xx,yy);
axis([-1,2.5,-1,2.5]);

回答 (4 件)

Walter Roberson
Walter Roberson 2013 年 2 月 17 日
編集済み: Walter Roberson 2013 年 2 月 17 日

0 投票

plot(xx, double(yy))
If that gets you the same error then examine sol and you will likely find that it has at least one free variable other than t.

2 件のコメント

Gandi Pirkov
Gandi Pirkov 2013 年 2 月 17 日
Error using mupadmex Error in MuPAD command: DOUBLE cannot convert the input expression into a double array.
If the input expression contains a symbolic variable, use the VPA function instead.
Error in sym/double (line 936) Xstr = mupadmex('symobj::double', S.s, 0);
Error in zad1 (line 8) plot(xx, double(yy));
I got this :(
Walter Roberson
Walter Roberson 2013 年 2 月 19 日
That indicates that your dsolve() result has at least one free variable beyond the 't' that you substituted in. "A"'s response pointing out that you would likely not have a "t" looks reasonable to me.

サインインしてコメントする。

A
A 2013 年 2 月 19 日
編集済み: A 2013 年 2 月 19 日

0 投票

Dear Gandi Pirkov,
the variable of your equation is x, why you are addressing t and xx?! I have modefied it, the following code works without error
plot([0,2],[0,0],'k'); plot([0,0],[0,2],'k');
sol=dsolve('D3y-3*D2y+y=-3*x','y(0)=0','Dy(0)=3','D2y(0)=0','x'); x = 0:0.1:2;
plot(x,subs(sol));
axis([-1,2.5,-1,2.5]);
Good Luck
omayma mansouri
omayma mansouri 2015 年 8 月 3 日

0 投票

Error using plot Conversion to double from sym is not possible. need help to solve this problem, thank you

1 件のコメント

omayma mansouri
omayma mansouri 2015 年 8 月 3 日
編集済み: omayma mansouri 2015 年 8 月 3 日
Error using plot Conversion to double from sym is not possible need help to solve this problem, thank you my code matlab

サインインしてコメントする。

Steven Lord
Steven Lord 2015 年 8 月 3 日

0 投票

Change your SUBS call to substitute xx in for x not t, since you told DSOLVE that your independent variable is x by specifying it as the final input argument.
yy = subs(sol, 'x', xx);

タグ

質問済み:

2013 年 2 月 17 日

回答済み:

2015 年 8 月 3 日

Community Treasure Hunt

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

Start Hunting!

Translated by