Same dimension for num and txt in xlsread

조회 수: 2 (최근 30일)
Christian
Christian 2015년 12월 11일
답변: Walter Roberson 2015년 12월 12일
Hi,
when I read in an excel file using xlsread, I'd like to have the outputs 'num' and 'txt' to have the same dimensions. It seems to me that by default, they chop off parts on the fringe that either don't contain numerics or text. It's convenient to have the same dimensions for reference purposes. For example, txt(1,2) should give me cell B1, and num(1,2) should also give me cell B1 in the original excel file.
Thanks, Christian
  댓글 수: 2
Kirby Fears
Kirby Fears 2015년 12월 11일
편집: Kirby Fears 2015년 12월 11일
Have you tried using the raw output of xlsread (output argument 3)? You can extract numerical and text data all from one object if you already know where (cell ranges) to find it.
[num,text,raw] = xlsread('myfile.xlsx');
Christian
Christian 2015년 12월 12일
Thank you. This works, but I have a very hard time working with 'raw'. The first column of 'raw' looks like this:
NaN
'Identifier'
NaN
NaN
NaN
NaN
NaN
NaN
NaN
NaN
NaN
1
and so on. It seems to be a cell. Now, I would like to find the row that has the number 1. That seems to be very tricky to do, not only because other cells might have the number 11 or so, and I only want the cell that has the number 1 and nothing else in there.

댓글을 달려면 로그인하십시오.

답변 (1개)

Walter Roberson
Walter Roberson 2015년 12월 12일
one_location = find( cellfun(@(C) isequal(C, 1), raw(:,1)) );

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by