Convert an array into floating numbers

Hello,
I have an dataset(49 by 9). I want to convert an array(49 by 1) in the dataset from exponential notation (e.g 1.003 e +03) into floating numbers.

回答 (1 件)

Matt J
Matt J 2013 年 6 月 11 日
編集済み: Matt J 2013 年 6 月 11 日

1 投票

Use STR2DOUBLE or STR2NUM.

10 件のコメント

Reyasudin
Reyasudin 2013 年 6 月 11 日
Actually, I want to convert an array of exponential values into floating numbers..not from string to numbers
Matt J
Matt J 2013 年 6 月 11 日
編集済み: Matt J 2013 年 6 月 11 日
Show me how to create a small array of the kind you're thinking of. I can't tell what you mean by "an array of exponential values" and its distinction from a floating point number. When I do this,
>> a=1.003e+03
a =
1003
I am creating a variable 'a' using exponential notation, but WHOS shows you immediately that it is a double floating point value.
>> whos a
Name Size Bytes Class Attributes
a 1x1 8 double
Reyasudin
Reyasudin 2013 年 6 月 11 日
I have a variable A that currently being displayed as {1.234e+03, 1.452e+03, 1.678e+03}. I want it to display like this{1235,1452, 1678}
tq
Matt J
Matt J 2013 年 6 月 11 日
Execute this at the command line and then re-display
>> format short
Reyasudin
Reyasudin 2013 年 6 月 11 日
Actually I did not create on my own the exponential data. It is already available in the dataset. Such as when I want to extract one row of variable x from dataset A
A.x(1) ans =
1.5625e+03
Reyasudin
Reyasudin 2013 年 6 月 11 日
編集済み: Reyasudin 2013 年 6 月 11 日
the format command does not solve it
Matt J
Matt J 2013 年 6 月 11 日
It doesn't matter how the data was created. Your question has nothing to do with the contents of the variable. Your question is about how to control the way it is displayed at the command line. See the FORMAT command for the different options.
>> doc format
Reyasudin
Reyasudin 2013 年 6 月 11 日
When I open the dataset, the variable in the dataset displayed in exponential format. That is why I want to change the whole column/ array into floating number.
Matt J
Matt J 2013 年 6 月 11 日
編集済み: Matt J 2013 年 6 月 11 日
When I open the dataset
You mean when you open it in the Variable Editor? Under the "View" menu, and within that under the "Numeric Array Format" menu there are options to change the way numbers are displayed (short, long, etc...). It is very similar to the FORMAT command.
Reyasudin
Reyasudin 2013 年 6 月 11 日
yes. that what I am asking..but there is no option to display the whole number..all the available option( short, long.....) will still show the number with exponential. I want it to display like shortg or longg number format. Maybe I cannot change it?

サインインしてコメントする。

カテゴリ

製品

質問済み:

2013 年 6 月 11 日

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by