Converting output results to 00e+00 form
6 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I have this:
iL=vpa(dsolve(eqn1,inits,'t'),4)
iL =
0.00467 - 0.0002202*exp(-133.2*t)*sin(2825.0*t) - 0.00467*exp(-133.2*t)*cos(2825.0*t)
How can I get the results like
iL = 4.67e-3 - 2.202e-4*exp(-1.332e+2t)*....
Thanks
0 comentarios
Respuestas (2)
Jonathan Epperl
el 11 de Nov. de 2012
Editada: Jonathan Epperl
el 11 de Nov. de 2012
So that you can change the output format by issuing
format STYLE
in your case
format shortE
you probably knew. And it won't help you here. The only idea I have is converting to string and doing some regular expression magic. So if iL is your symbolic expression. Then this command will get you a string res_str that contains the symbolic expression with all numbers (with decimals) converted to scientific notation
iL = 0.00467 - 0.0002202*exp(-133.2*t)*sin(2825.0*t)-.00467*exp(-133.2*t)*cos(2825.0*t)
res_str = regexprep(char(vpa(iL)),'([0-9]+\.[0-9]+)','${num2str(str2num($1),''%e'')}')
%res_str =
%4.670000e-03 - 2.202000e-04*exp(-1.332000e+02*t)*sin(2.825000e+03*t)-
%4.670000e-03*exp(-1.332000e+02*t)*cos(2.825000e+03*t)
(The extra vpa() command in regexprep is obviously unnecessary here if you called it on your expression earlier already)
Now if you reconvert to a sym, the numbers will be represented in the normal decimal format again, but that shouldn't be a problem: If you want to do algebra with it, use the sym variable, if you want to display use the string form.
2 comentarios
Jonathan Epperl
el 14 de Nov. de 2012
I don't think there's a way, but if you find one, let us know!
Walter Roberson
el 14 de Nov. de 2012
When you are going through the MATLAB interface, the only options you have for representation in MuPAD are those shown under "flag" in the documentation for "sym".
I do not have the symbolic toolbox to check against; it could be that by working more directly in MuPAD you could force an exponential notation.
0 comentarios
Ver también
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!