Skip to Main Content Skip to Search
Login
File Exchange
MATLAB Newsgroup
Link Exchange
  Blogs  
 Contest 
MathWorks.com

Thread Subject: variable sequence

Subject: variable sequence

From: Valerio

Date: 3 Jul, 2008 15:34:02

Message: 1 of 4

Hi
How can create a list of n variable, where n is an integer
value read from a file?
for example if n=5
i want that my program creates 5 variable named respectively
v1 v2 v3 v4 v5.
thank you

Subject: variable sequence

From: David

Date: 3 Jul, 2008 15:39:02

Message: 2 of 4

You can use eval.

For example,
n = 5;
for i = 1:n, eval(sprintf('v%d = []', i)); end



"Valerio " <garagorn@email.it> wrote in message <g4irha$3ql
$1@fred.mathworks.com>...
> Hi
> How can create a list of n variable, where n is an integer
> value read from a file?
> for example if n=5
> i want that my program creates 5 variable named
respectively
> v1 v2 v3 v4 v5.
> thank you
>

Subject: variable sequence

From: Steven Lord

Date: 3 Jul, 2008 16:28:13

Message: 3 of 4


"Valerio " <garagorn@email.it> wrote in message
news:g4irha$3ql$1@fred.mathworks.com...
> Hi
> How can create a list of n variable, where n is an integer
> value read from a file?
> for example if n=5
> i want that my program creates 5 variable named respectively
> v1 v2 v3 v4 v5.
> thank you

Don't do this. See Q4.6 in the FAQ:

http://matlabwiki.mathworks.com/MATLAB_FAQ

--
Steve Lord
slord@mathworks.com


Subject: variable sequence

From: Valerio

Date: 7 Jul, 2008 07:40:04

Message: 4 of 4

"Steven Lord" <slord@mathworks.com> wrote in message
<g4iumt$hbv$1@fred.mathworks.com>...
>
> "Valerio " <garagorn@email.it> wrote in message
> news:g4irha$3ql$1@fred.mathworks.com...
> > Hi
> > How can create a list of n variable, where n is an integer
> > value read from a file?
> > for example if n=5
> > i want that my program creates 5 variable named respectively
> > v1 v2 v3 v4 v5.
> > thank you
>
> Don't do this. See Q4.6 in the FAQ:
>
> http://matlabwiki.mathworks.com/MATLAB_FAQ
>
> --
> Steve Lord
> slord@mathworks.com
>
>
Thank you very much

Tags for this Thread

Add a New Tag:

Separated by commas
Ex.: root locus, bode

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.

rssFeed for this Thread

envelope graphic E-mail this page to a colleague

Public Submission Policy
NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Disclaimer prior to use.
Related Topics