Convert Cells with space entry to an empty cell

조회 수: 1 (최근 30일)
Caroline Hammoutene
Caroline Hammoutene 2016년 6월 30일
편집: José-Luis 2016년 6월 30일
Hey I have a problem: I import data from excel into matlab and I get a cell array. Something weird happens though: Whenn the cell is empty in excel, in matlab in some cases I get a NaN entry and in other cases I get this entry: ' ' I´d like both of them to be empty. Therefor I used
data = cellNaNReplace(data,[])
to replace the NaNs. But I am desperetly searching for a solution for the case of the entry ' '
I would be very happy in any case of good suggestions! Thanks

답변 (2개)

José-Luis
José-Luis 2016년 6월 30일
편집: José-Luis 2016년 6월 30일
a = { '', '', '', 'bla', 'bla';
'', 'bla', 'bla', 'bla', ''}
a(strcmp('',a)) = {[]}
Please remember to accept the answer that best solves your problem.
  댓글 수: 2
Caroline Hammoutene
Caroline Hammoutene 2016년 6월 30일
Unfortunately does not work, thank you anyways
José-Luis
José-Luis 2016년 6월 30일
편집: José-Luis 2016년 6월 30일
Does not work how? This assume you had gotten rid of the NaN s

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


Shameer Parmar
Shameer Parmar 2016년 6월 30일
Hello Caroline,
I dont know the direct command similar of what you used. like.. cellNaNReplace()
But I am sure, following solution will help you..
let us consider A is the cell array which you got from xlsread, which contains 'NaN' and ''.
for count = 1: length(A)
if isempty(A{count}) || isnan(A{count})
A{count} = [];
end
end
  댓글 수: 2
José-Luis
José-Luis 2016년 6월 30일
편집: José-Luis 2016년 6월 30일
length() would only work in the case of a column or vector array. You could use numel()
Caroline Hammoutene
Caroline Hammoutene 2016년 6월 30일
unfortunately isempty always returns 0 in this case

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

카테고리

Help CenterFile Exchange에서 Matrices and Arrays에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by