obtain numbers from mixed cells

1 vue (au cours des 30 derniers jours)
Irem Velibeyoglu
Irem Velibeyoglu le 7 Mai 2016
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!

Réponse acceptée

Azzi Abdelmalek
Azzi Abdelmalek le 7 Mai 2016
Modifié(e) : Azzi Abdelmalek le 7 Mai 2016
[num,str] = xlsread('fic.xlsx')
out=regexp(str,'[\d\.]+','match')
out=cellfun(@(x) str2double(x{:}),out)
  1 commentaire
Irem Velibeyoglu
Irem Velibeyoglu le 7 Mai 2016
Worked, thank you very much!

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Logical dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by