Cannot simplify a result

9 vues (au cours des 30 derniers jours)
Geovane Gomes
Geovane Gomes le 26 Mar 2022
Commenté : Geovane Gomes le 26 Mar 2022
Hi all,
I am trying to simplify at most the result of Td, but the maximum I get is (3*pi*39270^(1/2))/1666. When I put this result in command window it shows 1.1211, as I want, but not direct from the script.
I've already tried using simplify/simplifyFraction but didn't work.
Trust all clear
Thanks
clc
clear all
syms rho x L E w t csi
A=w*t;
I=(t*w^3)/12;
phi=(3*x^2)/(2*L^2) - x^3/(2*L^3);
phi1=diff(phi,x);
phi2=diff(phi,x,2);
Meq=int(rho*A*phi^2,x,0,L);
Keq=int(E*I*phi2^2,x,0,L);
ohmega=sqrt(Keq/Meq);
ohmegad=ohmega*sqrt(1-csi^2);
Td=2*pi/ohmegad;
Td=simplify((subs(Td,[E,w,L,rho,csi],[72e9,1,30,3000,0.02])))
Td = 

Réponse acceptée

Cris LaPierre
Cris LaPierre le 26 Mar 2022
Symbolic results are exact. If you want a decimal approximation, convert the symbolic value to a double.
syms rho x L E w t csi
A=w*t;
I=(t*w^3)/12;
phi=(3*x^2)/(2*L^2) - x^3/(2*L^3);
phi1=diff(phi,x);
phi2=diff(phi,x,2);
Meq=int(rho*A*phi^2,x,0,L);
Keq=int(E*I*phi2^2,x,0,L);
ohmega=sqrt(Keq/Meq);
ohmegad=ohmega*sqrt(1-csi^2);
Td=2*pi/ohmegad;
Td=simplify((subs(Td,[E,w,L,rho,csi],[72e9,1,30,3000,0.02])))
Td = 
% Convert Td to a double
Td_num = double(Td)
Td_num = 1.1211

Plus de réponses (1)

John D'Errico
John D'Errico le 26 Mar 2022
Modifié(e) : John D'Errico le 26 Mar 2022
You got a "numerical" result. But because the result is symbolic, that is the symbolic result. pi, and square roots are as you would expect in such a result. Then you tried to simplify them, but they were already in a maximally simple form as a symbolic result. It was not simplification you weree looking for, but to express them as floating point numbers.
You can turn them into actual floating point numbers using double. Or you can use vpa, to turn them into floaing point numbers, but as a symbolic form of a floating point number.
For example, you got this result:
X = str2sym('(3*pi*39270^(1/2))/1666')
X = 
As far as the symbolic toolbox is concerned, the job is done. That was fun, right? But you wanted real numbers. DOUBLE or VPA will do the job.
double(X)
ans = 1.1211
vpa(X)
ans = 
1.1210541248532242623574383591283
So double turns it into a double precision number, VPA turns it into a floating point number, but still in symbolic form. Here with 32 significant digits as the default for VPA, so roughly twice what a double gives you. (Remember that a double only displayed 5 digits there, but the number is stored as full double precision.)
  1 commentaire
Geovane Gomes
Geovane Gomes le 26 Mar 2022
Thanks!
Great explanation!
And yes. That was really fun

Connectez-vous pour commenter.

Produits


Version

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by