inputing pi in syms
Show older comments
Hello,
I am working with the code bellow & R2020a.
The answer provided is:
result: 
which is correct.
However, I would much prefare the answer to be given in the form:
aim: 
Is there a way to do so?
So far I tried using
pi = sym('pi')
and
pi = sym(pi)
or just pi as a symbol.
In the best senario I get the number answer (389.6364); in the worst I obtain this:
Thank you,
The code used:
syms k x L E I
pi = sym(pi)
% Trial function
w = k * (1- cos(2*pi*x/L))
% Derivatives
w_x = diff(w,x,1)
w_xx = diff(w,x,2)
% x_y = diff(w,y,1)
% x_yy = diff(w,y,2)
% Strain
U = 1/2* int((E*I*w_xx^2),[0,L])
5 Comments
madhan ravi
on 7 Jun 2020
Why do you expect the sun part to disappear?
Aleksander Tyczynski
on 7 Jun 2020
madhan ravi
on 7 Jun 2020
Yes but once you define pi using syms it doesn’t revalues the expression.
Aleksander Tyczynski
on 7 Jun 2020
Edited: Aleksander Tyczynski
on 7 Jun 2020
Surya Talluri
on 10 Aug 2020
I have checked with R2020a and the code that you have mentioned is working fine for me with sin(4pi) turning to zero.

Answers (0)
Categories
Find more on Conversion Between Symbolic and Numeric in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!