filling missing values with NA

12 views (last 30 days)
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

Accepted Answer

Rae Taylor-Burns
Rae Taylor-Burns on 6 Feb 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

More Answers (0)

Community Treasure Hunt

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

Start Hunting!