Interpolation and missing values
古いコメントを表示
I have a series of data given by an x array and a corresponding y array. The arrays are equal in size. The x array is approximately equally spaced, but it has a few small gaps, and some very large gaps. I would like to interpolate to get numeric values in the small gaps, but I'd like to replace the big gaps with NaNs.
Here is an example of some small gaps, and one big gap. I'd like to replace the obviously incorrect interpolation with NaNs. How can I do this?
% create some data:
x = 0:.02:15;
y = sin(x);
% create some holes in the data
x([3 25 32:33 200:280 410:415]) = [];
y([3 25 32:33 200:280 410:415]) = [];
plot(x,y,'ko'); hold on
% the interpolation I'd like to improve:
xi = 0:.015:15;
yi = interp1(x,y,xi,'cubic');
plot(xi,yi,'b.')
3 件のコメント
Image Analyst
2014 年 2 月 21 日
編集済み: Image Analyst
2014 年 2 月 21 日
To determine "hole" or "gap" size, it helps to have the Image Processing Toolbox. Do you have that? Type ver to find out. If you do you can use functions like bwareaopen() or regionprops() to easily determine the size of the hole.
Chad Greene
2014 年 2 月 21 日
Chad Greene
2014 年 2 月 21 日
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Matrices and Arrays についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!