decimal number as filed name of a structure
5 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Reza Reza
el 3 de En. de 2018
Respondida: Steven Lord
el 3 de En. de 2018
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'.
0 comentarios
Respuesta aceptada
the cyclist
el 3 de En. de 2018
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'
0 comentarios
Más respuestas (1)
Steven Lord
el 3 de En. de 2018
An alternative to regexprep is matlab.lang.makeValidName. A benefit of makeValidName is that you don't have to explicitly list all the possible invalid characters in your field name and their replacements. It doesn't care if the input is:
'One_IMj_4_Story_Selected_Records_Set_0.01SA_0.99dNSA' (periods)
'One_IMj_4_Story_Selected_Records_Set @ 0.01SA_0.99dNSA' (periods and @ symbol)
'1_IMj_4_Story_Selected_Records_Set_0.01SA_+ 0.99dNSA' (invalid first character, periods, space, and +)
etc.
0 comentarios
Ver también
Categorías
Más información sobre Whos en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!