inputing pi in syms
15 次查看(过去 30 天)
显示 更早的评论
Hello,
I am working with the code bellow & R2020a.
The answer provided is:
result: ![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/311507/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/311507/image.png)
which is correct.
However, I would much prefare the answer to be given in the form:
aim: ![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/311525/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/311525/image.png)
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:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/311513/image.png)
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 个评论
Surya Talluri
2020-8-10
I have checked with R2020a and the code that you have mentioned is working fine for me with sin(4pi) turning to zero.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/344023/image.png)
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Number Theory 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!