obtain numbers from mixed cells

조회 수: 1 (최근 30일)
Irem Velibeyoglu
Irem Velibeyoglu 2016년 5월 7일
댓글: Irem Velibeyoglu 2016년 5월 7일
I'm trying to import data from excel using xlsread command. In the original data, I have humidity values which are represented as for example "81 %". Matlab does not see this expression when I use
data = xlsread('filename.xlsx')
command. Then I tried
[num,str] = xlsread('filename.xlsx').
Now, num is an empty matrix and str is a vector of cells containing values such as 81 % in each cell.
I only want to obtain the value either as 0.81 or 81, it does not matter which I can obtain.
Can you help me obtain only the numbers from this vector of cells? Thanks!

채택된 답변

Azzi Abdelmalek
Azzi Abdelmalek 2016년 5월 7일
편집: Azzi Abdelmalek 2016년 5월 7일
[num,str] = xlsread('fic.xlsx')
out=regexp(str,'[\d\.]+','match')
out=cellfun(@(x) str2double(x{:}),out)
  댓글 수: 1
Irem Velibeyoglu
Irem Velibeyoglu 2016년 5월 7일
Worked, thank you very much!

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

추가 답변 (0개)

카테고리

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