필터 지우기
필터 지우기

fill missing cell array - code works but output wrong

조회 수: 3 (최근 30일)
Alexis Black
Alexis Black 2019년 9월 18일
답변: Beatriz Sanchez 2019년 9월 18일
I have a table with several cell array vectors; one looks like this:
VariableY
[1]
[1]
[1]
[]
[]
[2]
[2]
[]
[]
.... etc.
This is the code I'm using:
for i = 1:length(data.VariableY)
if isempty(data.VariableY{i})
data.VariableY{i} = fillmissing(data.VariableY{i}, 'previous');
end
end
I don't get an error - but the output doesn't change. What am I doing wrong? Thank you in advance!!
  댓글 수: 2
madhan ravi
madhan ravi 2019년 9월 18일
Try changing
if isempty(data.VariableY{i})
to
if any(isempty(data.VariableY{i}))
Alexis Black
Alexis Black 2019년 9월 18일
Thanks so much for the answer! Unfortunately, the output remains the same :/

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

답변 (1개)

Beatriz Sanchez
Beatriz Sanchez 2019년 9월 18일
Hello, I couldn't do it using the funtion fillmissing. You Can replace the missing values for a number o anything you want like this:
VariableY={missing(), 1, 1, 2, missing(), 2, 2, missing(), missing()}
mask= cellfun(@ismissing, VariableY)
VariableY(mask)= ['5']

카테고리

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

제품


릴리스

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by