filling missing values with NA

12 vues (au cours des 30 derniers jours)
Rae Taylor-Burns
Rae Taylor-Burns le 6 Fév 2020
Hey all,
I am trying to compare model output to observations, but some observations are missing, and I need to fill them with NAs in order to make plots.
My observations are in a struct. See the attached photos for a visual of what I'm working with.
Annotation 2020-02-06 11082.jpg
Annotation 2020-02-06 110823.jpg
I have tried a couple ways to fill missing values with NAs, but nothing has been successful so far - this is what I have tried:
for ii = 1:length(runs_wanted)
for jj = 1:length(results(ii).point)
missing = ismissing(observations(ii).point(jj).Hs_select)
observations(ii).point(jj).Hs_select(missing) = NaN
end
end
and
for ii = 1:length(runs_wanted)
for jj = 1:length(results(ii).point)
if observations(ii).point(jj).Hs_select == ' '
observations(ii).point(jj).Hs_select == Nan
end
end
end
If anyone could help me figure this out I'd really appreciate it!
Thanks all,
Rae

Réponse acceptée

Rae Taylor-Burns
Rae Taylor-Burns le 6 Fév 2020
Hello!
I have figured out the answer to my own problem - I pre-allocated all my observations as NaN, and then filled in with numbers after. Hope this helps anyone who has a similar issue!
Rae

Plus de réponses (0)

Catégories

En savoir plus sur Logical dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by