Is it possible to identify variables in the workspace that contain a string and save the identified variable with another name?
Show older comments
Is it possible to identify variables in the MATLAB workspace that contain a certain string and save that variable with a new name?
For example, search for variables containing "Position" then save the found variable with a new name? I'm working with data that is imported into the workspace where the exact variable name often changes but always contains a common string.
1 Comment
"Is it possible to identify variables in the MATLAB workspace that contain a certain string and save that variable with a new name?"
It is possible, if you really want to force yourself into writing slow, complex, inefficient, insecure, buggy code that is hard to debug:
"I'm working with data that is imported into the workspace where the exact variable name often changes but always contains a common string."
So far you have not told us the most important information: how are you importing that data into the workspace? The place where you import that data would be best place to fix this very badly designed data, not later once it is already in the workspace.
Accepted Answer
More Answers (0)
Categories
Find more on Structures in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!