sym(pi) version 2020a vs version 2019b

1 visualización (últimos 30 días)
Kai Kronewiter
Kai Kronewiter el 25 de Feb. de 2021
Respondida: Rishav el 21 de Feb. de 2024
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!

Respuestas (1)

Rishav
Rishav el 21 de Feb. de 2024
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

Productos


Versión

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by