Sym
You are now following this question
- You will see updates in your followed content feed.
- You may receive emails, depending on your communication preferences.
An Error Occurred
Unable to complete the action because of changes made to the page. Reload the page to see its updated state.
Show older comments
0 votes
Hi,
how can I change format of sym number? For example:
a=sym(2.34353453465464);
b=sym(4.6546455789879324352);
format short
c=a*b
Format short doesn't work.
Thanks
1 Comment
Sean de Wolski
on 1 Mar 2012
also note, b is converted to double before sym and some precision is lost
Accepted Answer
Andrew Newell
on 1 Mar 2012
1 vote
c = vpa(a*b,4)
11 Comments
john
on 1 Mar 2012
big thanks
john
on 6 Mar 2012
Hi, I have problem with my code: vpa works for "result", but I need show result in the uitable1, but for "res" command vpa doesn't work.
matrix=[A B;C D]
a=simple(matrix\X);
b=sym(a)
result=vpa(b,4)
f=size(result);
for i=1:f(1);
for j=1:f(2);
res(i,j)=cellstr(char(result(i,j)));
end
end
set(handles.uitable1,'Data',res);
Andrew Newell
on 6 Mar 2012
I suggest you make a new question of this.
john
on 6 Mar 2012
Hi,
if a=vpa(sym('ddddddd'),3), result is ddddddd
if a=vpa(sym('-ddddddd'),3) result is -1.0*ddddddd, but I don't like it, I would like have -ddddddd..
it is possible?
Andrew Newell
on 6 Mar 2012
I can't reproduce your result. If I type
vpa('1.234567',3)
vpa('-1.234567',3)
I get 1.23 and -1.23.
john
on 6 Mar 2012
You result is OK, but try it for symbolic objects for example vpa(sym('ddddddd'),3)......result is -1.0*ddddddd,,,,,or you have different result?
Andrew Newell
on 6 Mar 2012
I added sym() and the result was the same. What version of MATLAB are you using?
john
on 6 Mar 2012
7.12.0.635 (R2011a), and you?
Did you try with vpa(sym('-ddddddd'),3) also?
Walter Roberson
on 6 Mar 2012
MuPAD's unary minus gets converted automatically to -1 times the value, and there is no way to stop that conversion.
Overriding MuPAD's pretty-printer formatting for an expression is not much fun.
john
on 6 Mar 2012
ok,
thank you again
Andrew Newell
on 6 Mar 2012
I was using the Maple Toolbox.
More Answers (0)
Categories
Find more on Common Operations in Help Center and File Exchange
Tags
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)