sym(pi) version 2020a vs version 2019b

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!

답변 (1개)

Rishav
Rishav 2024년 2월 21일

0 개 추천

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:
  1. R2019b: https://www.mathworks.com/help/releases/R2019b/symbolic/sym.html
  2. R2020a: https://www.mathworks.com/help/releases/R2020a/symbolic/sym.html

카테고리

제품

릴리스

R2020a

질문:

2021년 2월 25일

답변:

2024년 2월 21일

Community Treasure Hunt

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

Start Hunting!

Translated by