Remove non-finite values while decimating
4 次查看(过去 30 天)
显示 更早的评论
I was able to decimate 8 other identical (or so I thought) files, but this one hit an error. Code and error below:
%% Set path
cd 'C:\folder'
%% Load data
data = readtable('data.csv');
%% Decimate and then convert to table format
data50_X = decimate(data{:,4},2);
Error using filtfilt
Expected input to be finite.
Error in filtfilt>efiltfilt (line 123)
validateattributes(x,{'double','single'},{'finite','nonempty'},'filtfilt');
Error in filtfilt (line 102)
y = efiltfilt(b,a,x);
Error in decimate (line 157)
odata = filtfilt(b,a,idata);
0 个评论
采纳的回答
Image Analyst
2023-11-1
Try this:
data = readtable('data.csv');
goodRows = isfinite(data{:, 4});
data = data(goodRows, :); % Extract only the good/finite values rows.
9 个评论
Image Analyst
2023-11-9
Sorry, you need another argument for all to make it apply across columns. Try this:
%% Load in your data (this may take a while, depdending on the size of the file)
data = readtable('small_data.csv');
%% Decimate and then convert to table format
goodRows = all(isfinite(data{:, 4:6}), 2);
data = data(goodRows, :) % Extract only the good/finite values rows
更多回答(1 个)
Matt J
2023-10-31
编辑:Matt J
2023-10-31
Likely, there are NaNs in your data that you have to remove.
find(~isfinite(data{:,4}))
5 个评论
Matt J
2023-11-1
find(~isfinite(data{:,4})) gives the locations of the bad data. You can go there and see what those values are, and either remove them or replace them with something else.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Numeric Types 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

