フィルターのクリア

How to convert 1.35678e-01 to numerical digits in matalb?

7 ビュー (過去 30 日間)
Ramanathan Anandarama Krishnan
Ramanathan Anandarama Krishnan 2019 年 7 月 18 日
Hello,
I am doing image processing and after segmentation i extract few Features like GLCM, entropy,Area etc. All these answers come as 1.3456e-01, 3.564676e+01 etc. . Is there any way to convert this to normal numerical numbers? I use Matlab 2014a. Please help me with respect to this.Thank you
  2 件のコメント
Joel Handy
Joel Handy 2019 年 7 月 18 日
What do you mean by "normal numerical numbers"? Those are normal numbers. Are those values coming back as strings you need to convert to numbers? If thats the case str2num or str2double will convert them. Otherwise its just display formatting. Try "format long g" to change how the command window displays numbers.
Ramanathan Anandarama Krishnan
Ramanathan Anandarama Krishnan 2019 年 7 月 18 日
Hello Joel Handy,
For example i use the following commands:
clc;
clear all;
close all;
a=imread('coins.png');
glcm=graycomatrix(a);
stats=graycoprops(a);
But i get output as follows:
Contrast: 1.2782e+04
Correlation: -0.0012
Energy: 1.7541e-05
Homogeneity: 0.0327
As u can see contrast and energy are in scientific notation. I need it in normal whole numbers like 0.005, 12345, 89898 etc. Please help me in this.

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

採用された回答

Adam Danz
Adam Danz 2019 年 7 月 18 日
" I need it in normal whole numbers like 0.005, 12345, 89898 etc"
Setting the format to longg (not long!) or shortg will solve the problem for the 'Contrast' value but not the 'Energy' value.
format longg
stats =
struct with fields:
Contrast: 12781.9263669137
Correlation: -0.00117293439093276
Energy: 1.75410617429713e-05
Homogeneity: 0.0326985233071923
format shortg
stats =
struct with fields:
Contrast: 12782
Correlation: -0.0011729
Energy: 1.7541e-05
Homogeneity: 0.032699
How will you be using the numbers? If you're just passing them on to another function this change in format does nothing. If you're printing them, you can convert them to strings like this
sprintf('%.6f',stats.Energy)
ans =
'0.000018'
  8 件のコメント
Walter Roberson
Walter Roberson 2019 年 7 月 21 日
They will all become datatype double when you load them from excel.
Ramanathan Anandarama Krishnan
Ramanathan Anandarama Krishnan 2019 年 7 月 21 日
編集済み: Ramanathan Anandarama Krishnan 2019 年 7 月 21 日
Then I have no problem. Thanks a lot Walter

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeImages についてさらに検索

製品


リリース

R2014a

Community Treasure Hunt

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

Start Hunting!

Translated by