Interpolate between columns within matrix to remove glitched data

1 次查看(过去 30 天)
Hi, I have a complex matrix where some colums contain glitched data. If columns 25,26 contains glitched data, how can I interpolate between the data in columns 24 and 27 in order to replace columns 25 and 26 within the matrix with the interpolated data?
Thanks

采纳的回答

Voss
Voss 2022-10-26
% a random matrix with 27 columns:
data = rand(10,27);
% glitch columns 25 and 26:
data(:,[25 26]) = NaN;
% show columns 24 to 27 for reference:
data(:,24:27)
ans = 10×4
0.1028 NaN NaN 0.4775 0.1076 NaN NaN 0.9803 0.5539 NaN NaN 0.5751 0.0611 NaN NaN 0.6417 0.9991 NaN NaN 0.8661 0.3203 NaN NaN 0.6451 0.8962 NaN NaN 0.5333 0.5412 NaN NaN 0.8923 0.7979 NaN NaN 0.2805 0.3862 NaN NaN 0.7574
% interpolate based on columns 24 and 27 to get new values for columns 25 and 26:
data(:,[25 26]) = interp1([1 4],data(:,[24 27]).',[2 3]).';
% show new columns 24 to 27:
data(:,24:27)
ans = 10×4
0.1028 0.2277 0.3526 0.4775 0.1076 0.3985 0.6894 0.9803 0.5539 0.5609 0.5680 0.5751 0.0611 0.2546 0.4482 0.6417 0.9991 0.9547 0.9104 0.8661 0.3203 0.4286 0.5368 0.6451 0.8962 0.7752 0.6543 0.5333 0.5412 0.6582 0.7753 0.8923 0.7979 0.6254 0.4529 0.2805 0.3862 0.5100 0.6337 0.7574

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Descriptive Statistics 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by