Unable to get sym(pi) to output Pi in matlab

1 view (last 30 days)
I am unable to use sym(pi) to provide pi as an output.
syms n positive integer
syms x real
Pi = sym(pi);
a0 = 1/Pi * int(x, 0, Pi)
The output runs as
1.5708
This code ran on friend's laptop giving π/2 as output. What could be the reason?
  1 Comment
Torsten
Torsten on 22 Oct 2024
Edited: Torsten on 22 Oct 2024
Which MATLAB version do you use ? In R2024b, the output for a0 is pi/2.
syms n positive integer
syms x real
Pi = sym(pi);
a0 = 1/Pi * int(x, 0, Pi)

Sign in to comment.

Answers (1)

Paul
Paul on 22 Oct 2024
Check your sympref
sympref
ans = struct with fields:
FourierParameters: [1 -1] HeavisideAtOrigin: 1/2 AbbreviateOutput: 1 TypesetOutput: 1 FloatingPointOutput: 0 PolynomialDisplayStyle: 'default' MatrixWithSquareBrackets: 0
Make sure that FloatingPointOutput is set to False.

Tags

Products


Release

R2024a

Community Treasure Hunt

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

Start Hunting!