I need help with an error "Undefined function or variable 'x'"

sym n x
w0 = pi; T0 = 2 ; n = 1:5;
a0 = (1/T0)*int(1,x,0,1)
an = (2/T0)*int(1*cos(n*w0*x),x,0,1)
bn = (2/T0)*int(1*sin(n*w0*x),x,0,1)

2 件のコメント

VBBV
VBBV 2020 年 10 月 2 日
編集済み: VBBV 2020 年 10 月 2 日
% if true
% code
% end
syms n x
w0 = pi; T0 = 2 ; n = 1:5;
a0 = (1/T0)*int(1,x,0,1)
an = (2/T0)*int(1*cos(n*w0*x),x,0,1)
bn = (2/T0)*int(1*sin(n*w0*x),x,0,1)
Olisa Iwoba
Olisa Iwoba 2020 年 10 月 2 日
Thanks a lot. Can't believe its just an 's' I missed after about an hour looking for the error

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

 採用された回答

Star Strider
Star Strider 2020 年 10 月 2 日

0 投票

The first line should be:
syms n x
that is, syms with a second ‘s’. (The sym call is to a valid function, however that syntax for it is wrong.)

その他の回答 (0 件)

カテゴリ

Community Treasure Hunt

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

Start Hunting!

Translated by