sym(pi) version 2020a vs version 2019b
1 回表示 (過去 30 日間)
古いコメントを表示
Hi,
I encountered a problem while executing a file written to calculate the fourier-coefficients of a function:
In version 2019b, it works totally fine, but in 2020a the code does not behave like I planned.
First of all, the code:
syms x k;
pi= sym(pi);
assume(k,'integer');
f = (x/pi)^3-x/pi; %function
u = -pi; %definition_interval_lower
o = pi; %definition_interval_upper
p = abs(o - u);
p=sym(p);
u = sym(u);
o = sym(o);
c = simplify(int(f.*exp(-1i*k*x*2*pi/p),x,u,o)/(p));
a = simplify(2*int(f.*cos(k*2*pi/p*x),x,u,o)/(p));
b = simplify(2*int(f.*sin(k*2*pi/p*x),x,u,o)/(p));
pretty(simplify(c))
pretty(simplify(a))
pretty(simplify(b))
In 2019b, the code returns the coefficients as a multiple of pi. In 2020a, MATLAB processes pi and returns the numerical result (for instance 0.3870 instead of 12/(pi^3)).
What do I have to change to get the result as a multiple of pi in version 2020a?
Thanks for your help!
0 件のコメント
回答 (1 件)
Rishav
2024 年 2 月 21 日
Hi Kai Kronewiter,
I ran the same code in MATLAB R2019b and R2020a, and I came across the same result in both the versions, where it returns the result in terms of 'pi'.
In case, there is any confusion, please refer to the below mentioned documentations for 'sym' for different versions:
0 件のコメント
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!