help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Creating "sequential variable names"


From: John W. Eaton
Subject: Re: Creating "sequential variable names"
Date: Mon, 18 Oct 2010 19:06:56 -0400

On 18-Oct-2010, Sergei Steshenko wrote:

| 
| 
| --- On Mon, 10/18/10, John W. Eaton <address@hidden> wrote:
| 
| > From: John W. Eaton <address@hidden>
| > Subject: Re: Creating "sequential variable names"
| > To: "AlbFrigerio" <address@hidden>
| > Cc: address@hidden
| > Date: Monday, October 18, 2010, 8:48 AM
| > On 18-Oct-2010, AlbFrigerio wrote:
| > 
| [snip]
| > If you find yourself using eval for what seem should be
| > normal
| > programming tasks, then you should immediately think there
| > must be a
| > better way, and nearly always there is.
| [snip]
| > jwe
| > 
| 
| I had difficulties using 'plot'. I.e. I needed a variable number 'X, Y, 
FORMAT' triplets, and I was generating a string representing the 'plot'
| command to be ultimately executed, then I used 'eval' to execute the
| command.
| 
| The triplets were generated in a loop and the string was filled in teh same 
loop.
| 
| So, which is a better way and is it described in the documentation ?
| I am still using octave-3.0.5 and reading 'help plot' I didn't find a way
| without 'eval'.

If I understand correctly what you are trying to do, then something
like the following should work:

  args = cell (nargs, 1);

  args{1} = x1;
  args{2} = y1;
  args{3} = fmt1;
  args{4} = x2;
  args{5} = y2;
  args{6} = fmt3;
  ...

  plot (args{:});

jwe


reply via email to

[Prev in Thread] Current Thread [Next in Thread]