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.

 Réponse acceptée

KSSV
KSSV le 19 Mai 2021
Modifié(e) : KSSV le 19 Mai 2021
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 commentaires

Thanks for your help, but it doesn't seem to work properly.
KSSV
KSSV le 19 Mai 2021
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 le 19 Mai 2021
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!

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Data Preprocessing dans Centre d'aide et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by