Conversion to double from sym is not possible

49 ビュー (過去 30 日間)
Tyler
Tyler 2011 年 11 月 14 日
回答済み: Shahid Iqbal 2019 年 6 月 30 日
syms n;
t = (-300:1:300);
D_n = ((sin((pi*n)/2))./(pi*n));
y = (D_n).*exp((-j)*n*t*(pi/100));
x = symsum(y,n,-10,-1) + symsum(y,n,1,10);
plot(t,x);
I would like to plot t vs. x, however I get the error 'Conversion to double from sym is not possible'.
  1 件のコメント
Christopher Creutzig
Christopher Creutzig 2011 年 11 月 17 日
Works fine for me. Are you using exactly the commands listed above? Which MATLAB version are you using? What does symvar(x) tell you?

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

回答 (2 件)

Walter Roberson
Walter Roberson 2011 年 11 月 14 日
Your x is a formula in terms of n, a variable you do not define a value for at any point.
Your t value has nothing to do with n.
You cannot plot a symbolic expression against an unrelated variable.
Perhaps what you want is
plot(t, double(subs(x,n,t)))
  1 件のコメント
BecauseHElives
BecauseHElives 2014 年 2 月 4 日
I had the same problem. This answer works.

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


Shahid Iqbal
Shahid Iqbal 2019 年 6 月 30 日
syms n;
t = (-300:1:300);
D_n = ((sin((pi*n)/2))./(pi*n));
y = (D_n).*exp((-1i)*n*t*(pi/100));
x = symsum(y,n,-10,-1) + symsum(y,n,1,10);
plot(t,x);
work properly just replace -j with -1i , use updated version of MATLAB.

Community Treasure Hunt

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

Start Hunting!

Translated by