School Assignment? Project Due Tomorrow? Chat LIVE With A Programming Expert!

Welcome to Dream.In.Code
Become an Expert!

Join 307,035 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 2,278 people online right now. Registration is fast and FREE... Join Now!




Floating Point Number Problem in Matlab

 

Floating Point Number Problem in Matlab

makis89

20 Oct, 2009 - 01:12 AM
Post #1

New D.I.C Head
*

Joined: 8 Apr, 2008
Posts: 19


My Contributions
Hi. I am facing a problem in Matlab. I have a column vector which goes like:

A =
9.2932e-005
5.6994e-004
3.1708e-003
1.9266e-002


What I want to do is, write those values in column vector G with 3 numbers after the comma. I want it to look like this:

A =
9.293e-005
5.699e-004
3.170e-003
1.926e-002

What I do is pass the vector in a string with sprintf where I set the format in '%.3e' and then pass that string into sscanf with the same format. Although the string follows the format I set, sscanf doesn't seem to work. The code goes like this:

CODE
STR=sprintf('%.3e ',A)
G=sscanf(STR,'%.3e')


G is returned empty after this^ Also sscanf returns Invalid Format.
Any suggestions ?

Kind regards

User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic

Time is now: 11/21/09 08:42AM

Live Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month