Cannot simplify a result
8 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Geovane Gomes
il 26 Mar 2022
Commentato: Geovane Gomes
il 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])))
0 Commenti
Risposta accettata
Cris LaPierre
il 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])))
% Convert Td to a double
Td_num = double(Td)
0 Commenti
Più risposte (1)
John D'Errico
il 26 Mar 2022
Modificato: John D'Errico
il 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')
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)
vpa(X)
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.)
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!