MATLAB: Decimal number as filed name of a structure field name how can I set this as field name ? since it has a decimal in it , Matlab doesn't accept it to be field name . If i could get rid of the dot, it works but i don't know how ? 'One_IMj_4_Story_Selected_Records_Set_0.01SA_0.99dNSA'. Best Answer You could find and replace the dots ...fn = 'One_IMj_4_Story_Selected_Records_Set_0.01SA_0.99dNSA'fn2 = regexprep(fn,'\.','_dot_')fn2 = 'One_IMj_4_Story_Selected_Records_Set_0_dot_01SA_0_dot_99dNSA' Related SolutionsMATLAB: Simple operations with struct idx = [struct_name.fieldname] > 50000;new_struct = struct_name(idx);new_struct will only contain elements where the field name is greater than 50000.If you don't want to delete those elements, and just want to set them to 0,new_struct = struct_name;idx = [new_struct.fieldname] > 50000;[new_struct(idx).fieldname] = deal(0);In this case, new_struct will have same elements as original struct_name but the elements set to 0. MATLAB: Want to combine 4 structures into 1 You shouldn't have numbered your variables in the first place. That only leads to problems. Put them together in an array.If I understood correctly, this should give you more or less what you want:Allsituations.Human = Human1;Allsituations.Auto = Auto1;Allsituations(2).Human = Human2;Allsituations(2).Auto = Auto2;Or as a more efficient but slightly more obscure one liner:Allsituations = struct('Human', {Human1, Human2}, 'Auto', {Auto1, Auto2}); Related QuestionSetting ytick marks on normplot does not behave as expectedUse conditions on a matrix and manipulate the resultsHow to compare string array with the names of structure’s fields.Ploting a function in a for loopMATLAB invalid field name
Best Answer