str2num function

53 views
Skip to first unread message

Alvin

unread,
Apr 26, 2011, 2:19:37 PM4/26/11
to freemat-devel
Hi, I just want to ask that the str2num function now can only handle
the string transform into double values
however, the data I try to handle is far more figures than that
are there any other method to execute this?
I have read about the eval function but I am still not understand
about that =[
thanks for your help! You guys really wrote a great programme! =)

Philip

unread,
Apr 28, 2011, 2:20:04 AM4/28/11
to freemat-devel
The point of your question is not clear. When you say you have
"far more figures", are you talking about the number of significant
figures in your input data?

The list of native data types at
http://freemat.sourceforge.net/help/sec_typecast.html
suggests that the floating-point "double" is the most accurate one
built into freemat. It is accurate to about 16 decimal digits:
http://en.wikipedia.org/wiki/Floating_point
If this number of significant figures is not enough for you, the
return
type of the str2num function is only the first of many challenges you
will face. (Google for "extended precision Knuth trick" if this is
indeed
your issue.)

Alvin

unread,
May 7, 2011, 3:50:30 PM5/7/11
to freemat-devel
Or can I ask my question in this way,
I want to read a file which the values is like this
-8.381903171539D-08
I am now only using this method below
eph(i).C_ic = str2num(str(23:37))*10^str2num(str(39:41));
but it can only archive poor accuracy like -8.3819e-008
how can I read all those number without losing accuracy?
Thank you very much for your answer anyway=]

Timothy Cyders

unread,
May 8, 2011, 8:53:35 AM5/8/11
to freema...@googlegroups.com
I believe you're getting the accuracy you want, but it's just not showing. Try typing:

format long

and then going through your commands. That will show more decimal places on the screen. If you can do a find and replace on your string formatted numbers to change the 'D' to 'E', you can just use eph(i).c_ic = str2num(str(23:41)).

TJ

--
You received this message because you are subscribed to the Google Groups "freemat-devel" group.
To post to this group, send email to freema...@googlegroups.com.
To unsubscribe from this group, send email to freemat-deve...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/freemat-devel?hl=en.


Alvin Chan

unread,
May 8, 2011, 9:20:38 AM5/8/11
to freema...@googlegroups.com
the problem solved! Thank you very much for your help!

Best Regards,
Alvin Chan
Reply all
Reply to author
Forward
0 new messages