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:
Automating variable naming

Subject: Automating variable naming

From: Blair

Date: 11 Dec, 2008 19:31:02

Message: 1 of 5

I'm trying to find a method to give unique names to workspace variables without having to manually do this in the workspace. I have a function which looks up Excel file names and puts them into a cell array. I'd like to use those unique file names to label the variable (matrix) that the larger function outputs, so that I can just automate processing and loop through. I'm taking Excel files, reading them and their filenames, doing slight manipulation/cleaning up, and then outputting in matlab.

I know this is a basic question, but it's frustrating that I'm unable to find the answer to this seemingly simple issue anywhere.

Thanks for the assistance!

Subject: Automating variable naming

From: Hardik Virani

Date: 11 Dec, 2008 19:38:52

Message: 2 of 5

Try

doc genvarname

-Hardik

"Blair " <bgoodridge@bren.ucsb.edu> wrote in message
news:ghrppm$6ua$1@fred.mathworks.com...
> I'm trying to find a method to give unique names to workspace variables
> without having to manually do this in the workspace. I have a function
> which looks up Excel file names and puts them into a cell array. I'd like
> to use those unique file names to label the variable (matrix) that the
> larger function outputs, so that I can just automate processing and loop
> through. I'm taking Excel files, reading them and their filenames, doing
> slight manipulation/cleaning up, and then outputting in matlab.
>
> I know this is a basic question, but it's frustrating that I'm unable to
> find the answer to this seemingly simple issue anywhere.
>
> Thanks for the assistance!

Subject: Automating variable naming

From: Andres

Date: 11 Dec, 2008 19:45:05

Message: 3 of 5

"Blair " <bgoodridge@bren.ucsb.edu> wrote in message <ghrppm$6ua$1@fred.mathworks.com>...
> I'm trying to find a method to give unique names to workspace variables without having to manually do this in the workspace. I have a function which looks up Excel file names and puts them into a cell array. I'd like to use those unique file names to label the variable (matrix) that the larger function outputs, so that I can just automate processing and loop through. I'm taking Excel files, reading them and their filenames, doing slight manipulation/cleaning up, and then outputting in matlab.
>
> I know this is a basic question, but it's frustrating that I'm unable to find the answer to this seemingly simple issue anywhere.

one after the other:
fileparts
genvarname
assignin

Regards
Andres

Subject: Automating variable naming

From: matt dash

Date: 11 Dec, 2008 19:52:02

Message: 4 of 5

"Blair " <bgoodridge@bren.ucsb.edu> wrote in message <ghrppm$6ua$1@fred.mathworks.com>...
> I'm trying to find a method to give unique names to workspace variables without having to manually do this in the workspace. I have a function which looks up Excel file names and puts them into a cell array. I'd like to use those unique file names to label the variable (matrix) that the larger function outputs, so that I can just automate processing and loop through. I'm taking Excel files, reading them and their filenames, doing slight manipulation/cleaning up, and then outputting in matlab.
>
> I know this is a basic question, but it's frustrating that I'm unable to find the answer to this seemingly simple issue anywhere.
>
> Thanks for the assistance!

Check out the function genvarname. Though I'm afraid to actually use the names it comes up with you'll have to use eval.

Subject: Automating variable naming

From: Blair

Date: 11 Dec, 2008 20:42:02

Message: 5 of 5

Got it, thanks all for the help!

"Blair " <bgoodridge@bren.ucsb.edu> wrote in message <ghrppm$6ua$1@fred.mathworks.com>...
> I'm trying to find a method to give unique names to workspace variables without having to manually do this in the workspace. I have a function which looks up Excel file names and puts them into a cell array. I'd like to use those unique file names to label the variable (matrix) that the larger function outputs, so that I can just automate processing and loop through. I'm taking Excel files, reading them and their filenames, doing slight manipulation/cleaning up, and then outputting in matlab.
>
> I know this is a basic question, but it's frustrating that I'm unable to find the answer to this seemingly simple issue anywhere.
>
> Thanks for the assistance!

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