Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
batch re-nameing items in workspace

Subject: batch re-nameing items in workspace

From: Kirk

Date: 9 Aug, 2011 14:14:30

Message: 1 of 2

I have a bunch of structs in my workspace that I would like to rename by adding a tag onto the front of the struct name.

Something like:

old_x
old_y
old_z

new_x
new_y
new_z

I was looking for some way to use regular expressions to do this, but perhaps there is a better way. Any suggestions would be appreciated.

Subject: batch re-nameing items in workspace

From: Sven

Date: 11 Aug, 2011 00:28:28

Message: 2 of 2

"Kirk" <kwythers.nospam@umn.edu> wrote in message <j1rfc6$q41$1@newscl01ah.mathworks.com>...
> I have a bunch of structs in my workspace that I would like to rename by adding a tag onto the front of the struct name.
>
> Something like:
>
> old_x
> old_y
> old_z
>
> new_x
> new_y
> new_z
>
> I was looking for some way to use regular expressions to do this, but perhaps there is a better way. Any suggestions would be appreciated.

x = 'asfd'
y = 'asfdwerwe'
varNames = {'x','y'}
for i = 1:length(varNames)
  varName = varNames{i};
  assignin('base', ['new_' varName], evalin('base', varName))
end

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us