Error with fillmissing syntax

Hello,
I have a simple 274x108 matrix A with numbers and NaNs.
I want to replace the Nans with interpolated values using fillmissing.
I would like to use the parameter 'MaxGap' — Maximum gap size to fill.
dim = 1;
[F,TF] = fillmissing(A,'linear',dim,'MaxGap',2);
No matter how I try to use it, it returns:
Error using fillmissing/parseInputs (line 455)
Fill method must be 'constant', 'previous', 'next', 'nearest', 'linear', 'spline', 'pchip',
'makima', 'movmean', or 'movmedian'.
How do you use the MaxGap parameter?
Thank you in advance!
Charles

6 个评论

Which release are you using? 'MaxGap' was introduced after R2019b altho doc's don't provide when the more recent additions were let out. I'm guessing the release you have just doesn't know what the option is and so is getting confused in the parsing and the error message is best it can do.
Other than that, syntax looks ok although to go by column you don't need to specify the dimension so you might just try
[F,TF] = fillmissing(A,'linear','MaxGap',2);
for grins to make sure something else hasn't been buggered in the input parsing.
Thankyou for your response dpb.
I am using realease 2020a.
Also, I see your point about the dimension but I need to do this along different dimensions too, so keeping the syntax dim is important.
Nevertheless, I tried what you suggested, and, still got the same error.
Event with a very simple matrix:
A= [1 0 2 nan 3; 5 nan 2 3 nan]
[F,TF] = fillmissing(A,'linear','MaxGap',2);
I get the same error.
Adam Danz
Adam Danz 2020-12-11
编辑:Adam Danz 2020-12-11
I don't see anything wrong with this syntax.
Open fillmissing.m and place a break point at the line that checks the fillMethod against the validIntMethods, it should be at or very close to line 455 in 20a (line 505 in 20b). Then run your code and look at the value of fillMethod.
Which release actually introduced 'MaxGap'?
Release notes for R2020b talk about it; it's not clear to me exactly what it means -- is this a behavior change or the introduction? Or is this just in the Live Editor? Pretty nebulous.
Surely wish TMW would also document in the doc these dates when new stuff is introduced besides just when the function itself was introduced.
fillmissing Function and Clean Missing Data Live Editor Task: Specify maximum gap size to fill
When filling missing data using the fillmissing function, you can use the 'MaxGap' name-value pair to fill only gaps of missing data up to a specified size. When using the Clean Missing Data Live Editor task, enter a gap size next to Max gap to fill.
MaxGap wasn't an option prior to r2020b
Here's documentation for 20a and that parameter isn't mentioned
Thank you Adam.
Sometimes I read the documentation online as it feels more convenient to navigate, and I didn't notice this parameter was not available in my release's doc.

请先登录,再进行评论。

 采纳的回答

Farbos de Luzan
Farbos de Luzan 2020-12-11
编辑:Farbos de Luzan 2020-12-11

0 个投票

Just installed r2020b.
It works now.
As Adam said:
MaxGap wasn't an option prior to r2020b

更多回答(1 个)

Adam,
The function stopped at line 455 when I tried
[F,TF] = fillmissing(A,'MaxGap',0.1);
which was a syntax error I admit.
With the syntax used here
[F,TF] = fillmissing(A,'linear','MaxGap',2);
the function stops at line 127
Error using fillmissing/parseInputs (line 538)
Parameter name must be 'EndValues', 'SamplePoints', or 'DataVariables'.
Error in fillmissing (line 127)
[A,AisTable,intM,intConstOrWinSize,extM,x,dim,dataVars,ma] =
parseInputs(A,fillMethod,varargin{:});
Should I try to install R2020b?

类别

帮助中心File Exchange 中查找有关 Data Preprocessing 的更多信息

产品

版本

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by