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
참고 항목
카테고리
Help Center 및 File Exchange에서 Calculus에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!