MATLAB: How delete empty fields in a struct emptyfieldstruct Hi! I have a struct (attached) and I want to delete the empty field, how can I do? Best Answer out = {t(~cellfun(@isempty,{t.places})).places};t = cell2struct(out,{'places'},1);or jastt = t(~cellfun(@isempty,{t.places})); Related SolutionsMATLAB: How to remove empty struct fields [ ] from a group a struct fields Does this do what you want?% create a structure with empty fieldsS.A = 'x' ; S.B = [] ; S.C = 1:5 ;fn = fieldnames(S)tf = cellfun(@(c) isempty(S.(c)), fn)S2 = rmfield(S, fn(tf)) MATLAB: How to check if there is any field in structure isempty(fieldnames(L1)) Related QuestionDelete empty field from struct to allow polyfit to workHow to delete field in struct in loopTo delete the empty fields in the datasetDelete empty field – rows in a structureHow to create a structure inside a structureArray of structures in matlab
Best Answer