How to replace 'genvarname' with 'matlab.la​ng.makeVal​idName'?

Hi,
I'm using 'genvarname' to create variables names from strings. Example:
temp = 'abc'
v = genvarname(temp)
eval([v,'=5'])
Result
abc = 5
In Matlab 2017a I've got a suggestion to replace 'genvarname' with 'matlab.lang.makeValidName' as 'getvarname' will be removed from future releases. Could anyone help me with rewriting my example using 'matlab.lang.makeValidName'?

 Respuesta aceptada

ES
ES el 21 de Mzo. de 2017
temp = 'abc'
v = matlab.lang.makeValidName(temp)
eval([v,'=5'])

1 comentario

Well, thanks a lot, but I'm a bit ashamed... I've tried that before but didn't work - seems I've made some mistakes. Thanks!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Variables en Centro de ayuda y File Exchange.

Preguntada:

el 21 de Mzo. de 2017

Editada:

el 21 de Mzo. de 2017

Community Treasure Hunt

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

Start Hunting!

Translated by