replace NaN value without disturb or remove important peak
4 ビュー (過去 30 日間)
古いコメントを表示
Here im attached my example data and plot image of the data, i have problem to replace the NaN value without disturb the ploting trend or remove important peak. Can anyone help me to solve this problem?
If you see from data im attach, the NaN value located something at center and the end of the data. i want to make the ploting to be continuous without remove number of data and try to keep the trend also important peak.

0 件のコメント
回答 (2 件)
Star Strider
2025 年 4 月 9 日
編集済み: Star Strider
2025 年 4 月 12 日
M1 = readmatrix('41679.2500000000.txt');
X1 = linspace(0, numel(M1), numel(M1)).';
FM1 = fillmissing(M1, 'linear');
Lv = isnan(M1);
nnz(Lv)
Lv1 = strfind(Lv.', [0 1]).'; % Segment Start Indices
Lv2 = [strfind(Lv.', [1 0]); numel(M1)]; % Segment End Indices
figure
plot(X1, M1)
hold on
for k = 1:numel(Lv1)
idxrng = Lv1(k) : Lv2(k);
plot(X1(idxrng), FM1(idxrng), '--r')
end
hold off
grid
.
EDIT — (9 Apr 2025 at 11:43)
Corrected typographical errors.
EDIT — (12 Apr 2026 at 13:23)
The interpolated vector ‘FM1’ has all the necessary values and no NaN gaps —
figure
plot(X1, FM1)
grid
.
0 件のコメント
Thorsten
2025 年 4 月 10 日
y = readmatrix('41679.2500000000.txt');
x = 1:numel(y);
yi = interp1(x(~isnan(y)), y(~isnan(y)), x, 'linear', 'extrap');
plot(x, yi)
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Annotations についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!