Matlab: renaming workspace elements from command window?

11,460

You can rename variables in the command window as follows:

%# create a variable
a = 3;

%# rename a to b
b = a;clear('a');

EDIT

If you want to rename your variable to another variable stored in a string, you can use ASSIGNIN

a = 3;
newVarName = 'b';
assignin('base',newVarName,a);
clear('a') %# in case you want to get rid of the variable a
Share:
11,460
Mike
Author by

Mike

Updated on June 04, 2022

Comments

  • Mike
    Mike almost 2 years

    The GUI of Matlab allows me to rename any element in the workspace by right-clicking on the element and selecting the 'rename' option. Is it possible to do this from the command window as well?