Be the first to rate this file! 7 downloads (last 30 days) File Size: 2.06 KB File ID: #13824

exp2text

by Vasilis Kapetanidis

 

31 Jan 2007 (Updated 01 Feb 2007)

No BSD License  

Converts exponential format to TeX format for annotating plots

Download Now | Watch this File

File Information
Description

This should be a useful small function for anyone who doesn't like the classic "scientific notation" format and would like to have a more compact notation for their plots.

With exp2text you can convert any real or complex number to an appropriate exponential format using multiples of a power of 10 in a *10^ form instead of the classic 'E' exponential notation (see screenshot)

Number of desired significant digits can also be included as a parameter (default is 3)

Example shown in screenshot:

x=0.0014982; % Real Number Example
 y=0.1341+0.325i; % Complex Number Example
 figure
 text(0.1,0.95,['\bf{Real Numbers:}'])
 text(0.1,0.9,['Simple num2str: ',num2str(x)])
 text(0.1,0.85,['Simple exp format: ',num2str(x,'%.3e')])
 text(0.1,0.75,['exp2text: ',exp2text(x)])
 text(0.1,0.55,['\bf{Complex Numbers:}'])
 text(0.1,0.5,['Simple num2str: ',num2str(y)])
 text(0.1,0.45,['Simple exp format: ',num2str(y,'%.3e')])
 text(0.1,0.35,['exp2text: ',exp2text(y)])

MATLAB release MATLAB 7 (R14)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Please login to add a comment or rating.
Updates
01 Feb 2007

minor change in example code

Tag Activity for this File
Tag Applied By Date/Time
annotation Vasilis Kapetanidis 22 Oct 2008 08:59:01
customization Vasilis Kapetanidis 22 Oct 2008 08:59:01
tex Vasilis Kapetanidis 22 Oct 2008 08:59:01
exponential Vasilis Kapetanidis 22 Oct 2008 08:59:01
format Vasilis Kapetanidis 22 Oct 2008 08:59:01
text Vasilis Kapetanidis 22 Oct 2008 08:59:01
numbers Vasilis Kapetanidis 22 Oct 2008 08:59:01
real Vasilis Kapetanidis 22 Oct 2008 08:59:01
complex Vasilis Kapetanidis 22 Oct 2008 08:59:01
 

MATLAB Central Terms of Use

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Terms prior to use.

Contact us at files@mathworks.com