Hi there! I'm having an issuse with filling empty elements and then marking them with red dots. Here is what i got:
F = standardizeMissing(d1, Inf);
F(isnan(F))=0;
plot(F,'.r', 'MarkerSize', 15)
hold on
plot(F,'b')
It fills the empty values but on the plot, it marks all of the points, not only the ones that were empty.

 채택된 답변

KSSV
KSSV 2021년 5월 19일
편집: KSSV 2021년 5월 19일

0 개 추천

idx = isnan(F);
id1 = find(idx) ;
id2 = find(~idx) ;
% Fill missing
F(idx) = interp1(id2,F(id2),id1) ;
plot(id1,F(idx),'.r', 'MarkerSize', 15)
hold on
plot(1:length(F),F,'b')

댓글 수: 7

Thanks for your help, but it doesn't seem to work properly.
KSSV
KSSV 2021년 5월 19일
You need to provide the indices. Edited the code.
I think you didn't actually understand what I mean. I have to fill missing places and put red dots where the misssing places existed. Like in this example:
KSSV
KSSV 2021년 5월 19일
Edited the code.....you can also use fillmissing an inbuilt function to fill the missing/ NaN values.
I've tried with fillmissing as well. Didn't work for me. I applied the code you sent me, the NaN values are changing, but the values that were previously NaN are still not marked with the red dots.
F = rand(1,10) ;
F(2) = NaN ;
F(5) = NaN ;
F(7) = NaN ;
idx = isnan(F);
id1 = find(idx) ;
id2 = find(~idx) ;
% Fill missing
F(idx) = interp1(id2,F(id2),id1) ;
plot(id1,F(idx),'.r', 'MarkerSize', 15)
hold on
plot(1:length(F),F,'b')
Thanks a lot!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Data Preprocessing에 대해 자세히 알아보기

질문:

2021년 5월 19일

댓글:

2021년 5월 19일

Community Treasure Hunt

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

Start Hunting!

Translated by