How to remove NaNs from .struct

I have one .struct. Inside this there are 3 different .struct. These .struct have 50-70 different variables (date, time, numbers) (attached here)
I want to remove all the NaNs or replace them with 0 .
Thank you!!

7 Comments

Used this codefor Tables & NOT structure --> F = fillmissing(A,'constant',0,'DataVariables',@isnumeric)
fillmissing() accepts
Input data, specified as a vector, matrix, multidimensional array, cell array of character vectors, table, or timetable.
It does not accept a struct() as its input.
Is there a particular struct field that needs to be examined for NaN?
Or is it the case that you need to examine all of the numeric fields at a given level, find the positions that are NaN in any of the fields at that level, and remove or zero all of the fields at those locations ?
So for example if NSOL(3) is nan and M_SOLL(7) is nan, then Zeit(3) and Zeit(7) should be filled with duration 0 ? and datetime Datum(3) and Datum(7) should be filled with...
datetime(0,0,0,0,0,0)
ans = datetime
30-Nov--0001
?
Yes that's what my requirement is. Since I could not do it for .struct, I converted it into table and did the necessary operation and then converted it back into .struct.
@Ashishkumar Gupta you know from your prior question, or at least you should, that you need to attach your structure. Come on, make it easy for us to help you, not hard. Save it to a .mat file and attach it.
If you have any more questions, then attach your data and code to read it in with the paperclip icon after you read this:
Converting to table is not a bad approach.
Hi @Image Analyst. Sorry for the inconvenience caused. I am new here, so did not know that I have to attach a file.
But yeah, I got a solution to my problem!!!!
Thanks everyone...

Sign in to comment.

Answers (0)

Categories

Community Treasure Hunt

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

Start Hunting!