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

Ashishkumar Gupta
Ashishkumar Gupta 2023년 1월 5일
편집: Ashishkumar Gupta 2023년 1월 6일
Used this codefor Tables & NOT structure --> F = fillmissing(A,'constant',0,'DataVariables',@isnumeric)
Walter Roberson
Walter Roberson 2023년 1월 5일
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
?
Ashishkumar Gupta
Ashishkumar Gupta 2023년 1월 6일
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.
Image Analyst
Image Analyst 2023년 1월 6일
@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:
Walter Roberson
Walter Roberson 2023년 1월 6일
Converting to table is not a bad approach.
Ashishkumar Gupta
Ashishkumar Gupta 2023년 1월 6일
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...

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

답변 (0개)

카테고리

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

태그

질문:

2023년 1월 5일

댓글:

2023년 1월 6일

Community Treasure Hunt

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

Start Hunting!

Translated by