error reading excel

조회 수: 9 (최근 30일)
kash
kash 2012년 2월 14일
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

채택된 답변

Ken Atwell
Ken Atwell 2012년 2월 14일
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.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Data Type Conversion에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by