Interpolate include NaN data.

1 回表示 (過去 30 日間)
Jeong_evolution
Jeong_evolution 2016 年 11 月 14 日
コメント済み: Jeong_evolution 2016 年 11 月 18 日
Data likes this
-----
3
NaN
NaN
7
NaN
NaN
2
NaN
NaN
19
NaN
NaN
12
-----
How interpolate NaN data?
I try interp1 fuction. But I failed.
Please help me.
  1 件のコメント
Jan
Jan 2016 年 11 月 14 日
Whenever you post "failed" in the forum, add your code and explain the error.

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

採用された回答

John D'Errico
John D'Errico 2016 年 11 月 14 日
編集済み: John D'Errico 2016 年 11 月 14 日
Download inpaint_nans from the File Exchange. Although interp1 would also have been able to solve the problem too. inpaint_nans is far simpler to use for this though.
  4 件のコメント
John D'Errico
John D'Errico 2016 年 11 月 14 日
This is easier?
k = find(~isnan(x));
y = interp1(x(k),y(k),1:numel(x));
It is not difficult. But you cannot claim it to be simpler to use interp1 here.
Jeong_evolution
Jeong_evolution 2016 年 11 月 18 日
I'm sorry. I didn't work hard.
Very easy.. Thanks ^^

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

その他の回答 (1 件)

Jan
Jan 2016 年 11 月 14 日
data = [3, NaN, NaN, 7, NaN, NaN, 2, NaN, NaN, 19, NaN, NaN, 12];
miss = isnan(data);
data(miss) = interp1(data(~miss), find(~miss), find(miss))
  4 件のコメント
Jeong_evolution
Jeong_evolution 2016 年 11 月 18 日
Mr.Simon. This is real data.
When I try this code used real data, there was an error.
But I don't know mean. You know?
Jeong_evolution
Jeong_evolution 2016 年 11 月 18 日
Code is
------------------------------------------------------------------------------------
AA = xlsread('TMY_original_mssing_2');
data = AA(:,1:3);
miss = isnan(data);
data(miss) = interp1(data(~miss), find(~miss), find(miss));
------------------------------------------------------------------------------------

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

カテゴリ

Help Center および File ExchangeInterpolation of 2-D Selections in 3-D Grids についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by