error reading excel

7 Ansichten (letzte 30 Tage)
kash
kash am 14 Feb. 2012
I displayed data after using xlsread
raw =
Columns 1 through 5
[39] ' State-gov' [ 77516] ' Bachelors' [13]
[50] ' Self-emp-not-inc' [ 83311] ' Bachelors' [13]
[38] ' Private' [215646] ' HS-grad' [ 9]
[53] ' Private' [234721] ' 11th' [ 7]
[28] ' Private' [338409] ' Bachelors' [13]
[37] ' Private' [284582] ' Masters' [14]
[49] ' Private' [160187] ' 9th' [ 5]
I performed an operation
txt=strrep(txt,'Self-emp-not-inc','0.13');
i did same for private,State-gov,Bachelor,etc
Val = str2double(txt)
i get those values corect but other column 1,3,5 are displayed as NAN
PLEASE HELP ,after performing these operation i dont need nan ,i need only actual column 1,3,5 to be displayed as it is

Akzeptierte Antwort

Ken Atwell
Ken Atwell am 14 Feb. 2012
xlsread returns (up to) three values, and it appears you are capturing all three:
  • numeric results (only)
  • text results (only)
  • raw -- numeric and text results (mixed)
Make sure you're performing your post-processing operations on the right result. I'm guessing that "str2double(txt)" is not working for you because you're doing that operation on the text-only results (the second argument). You would want to call str2double on the third output. Or, it is likely the first output already captures what you are interested in.

Weitere Antworten (0)

Kategorien

Mehr zu Data Type Conversion finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by