interpolating the NaNs in Cell array - 180x1

I have a Cell vector - I have tried everything i am still getting an error, i am using matlab 2018b version, i am looking for the answer how to interpolate the NaNs in my cell array

回答 (2 件)

KSSV
KSSV 2020 年 8 月 14 日

1 投票

Let (x,y) be your data where x and y are n*1 arrays each. Say you have NaN's in y and you want to fill them.
idx = isnan(y) ;
y(idx) = interp1(x(~idx),y(~idx),x(idx)) ;

3 件のコメント

ANIL TUNCAY
ANIL TUNCAY 2020 年 8 月 14 日
%% Daily to Monthly Exchange Rate
numRawExchangeRate = table2array(rawExchangeRate);
dt = datetime(('01/01/2000') : datetime('31/12/2014'))';
tt = timetable(dt, numRawExchangeRate);
averageMonthly = retime(tt, 'Monthly');
monthlyExchangeRate = averageMonthly.numRawExchangeRate;
monthlyexchangeRate1 = cell2table(monthlyExchangeRate);
monthlyexchangeRate1 = monthlyexchangeRate1(1:end-1, :);
so this is my table but as soon as i try isnan i am getting -
Undefined function 'isnan' for input arguments of type 'table'.
ANIL TUNCAY
ANIL TUNCAY 2020 年 8 月 14 日
even I used ismissing but then it's not displaying the NaN it's showing whole data 0s meaning like there is no missing values
ANIL TUNCAY
ANIL TUNCAY 2020 年 8 月 14 日
thank you for the help in advance by the way

サインインしてコメントする。

Bruno Luong
Bruno Luong 2020 年 8 月 14 日

1 投票

y = fillmissing(y,'linear')

2 件のコメント

ANIL TUNCAY
ANIL TUNCAY 2020 年 8 月 14 日
i have tried this too but it is not changing with this - after doing this with different methods spline, previous etc. my data is still with the NaNs
ANIL TUNCAY
ANIL TUNCAY 2020 年 8 月 14 日
thank you for the help in advance by the way

サインインしてコメントする。

カテゴリ

質問済み:

2020 年 8 月 14 日

コメント済み:

2020 年 8 月 14 日

Community Treasure Hunt

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

Start Hunting!

Translated by