Unable to convert expression into double array
1 次查看(过去 30 天)
显示 更早的评论
Following code produces the error for 'while abs(double(subs(diff))) < 1/10'
syms f(t)
syms t
syms n
T = 2*pi;
w1 = 1;
t2 = linspace(-1, 1, 10);
f(t) = piecewise(-pi<t<0, (4+t)/2, 0<=t<pi, (2-t).*cos(2*t));
Cn = (int(f(t) * exp(-1j * n * w1 * t), -T/2, T/2))/T;
n = 1;
f(t2);
diff = 0;
while abs(double(subs(diff))) < 1/10
Cn = (int(f(t) * exp(-1j * n * w1 * t2), -T/2, T/2))/T
Sn = Cn.*exp(1j * n * w1 * t);
diff = abs(f(t2)-Sn)
diff = simplify(diff)
diff = vpa(diff)
n = n + 1;
end
n
Anyone know what i can do? Cheers
0 个评论
回答(1 个)
KSSV
2021-4-8
This line:
subs(diff)
You have to substitute some value right? I guess you need to input value of t here......
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Number Theory 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!