Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Writing out a specific format

1 view
Skip to first unread message

Bill

unread,
Nov 9, 2009, 1:04:03 PM11/9/09
to
Hello everyone,

I have a group of numbers that I am trying to write out in a specific format. When I look at formating strings within Matlab's help, I don't see the format I am looking for. In general, the field width must be no wider than 8 characters to include the exponential and sign. Note that the format can be fixed or exponential, depending on which one is more compact. If it is an exponential, it does not have e or E. Instead, it uses a + or - sign.

Listed below are some examples of what I need. This should be familiar to NASTRAN users.

Unformatted Formatted
2.437366E-03 2.4374-3
-2.437366E-03 -2.437-3
2.9E7 2.9+7
100.0 100.

Thanks.

Best regards,

Bill Rooker

dpb

unread,
Nov 9, 2009, 1:19:25 PM11/9/09
to
Bill wrote:
...
...

About best you'll do w/ ML pre-written will be w/ the "g" format
descriptor but it won't do the exponential w/o the E (and I'm not at all
sure you can force only one instead of two digits).

Think you'll have to write a function that parses the output of
sprintf() and strips the E and does the other cleanup, sorry.

--

0 new messages