How to change variable name from known string?

37 views (last 30 days)
Given: I have variable "Old_var=55" and string "New_var".
Want: How to change name from Old_var to New_var by using code, so I will have new variable "New_var=55".

Accepted Answer

Azzi Abdelmalek
Azzi Abdelmalek on 1 Jul 2015
assignin('base',Old_var,'New_var')
  1 Comment
Ivan Shorokhov
Ivan Shorokhov on 1 Jul 2015
Thank you, but another way around.
assignin('base','New_var', Old_var )

Sign in to comment.

More Answers (0)

Categories

Find more on MATLAB in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!