help-octave
[Top][All Lists]
Advanced

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

Re: How to create automatically the variable name


From: Sergei Steshenko
Subject: Re: How to create automatically the variable name
Date: Sun, 24 Jun 2018 08:00:42 +0000 (UTC)



On Sunday, June 24, 2018, 10:51:50 AM GMT+3, Leloup <address@hidden> wrote:


Hello,
    I should like creating automatically the variable name. I tried :
>>for K = 1:3,name = ["A",num2str(K)],endfor
name = A1
name = A2
name = A3
However that fails because I need to associate to each variable A1, A2 to
data. For example A1 = 1, A2 = 2...
I tried:
>> for K = 1:10,["A",num2str(K)] = K,endfor
parse error:  invalid left hand side of assignment
>> for K = 1:3,A{K} = K,endfor
A =
{
  [1,1] =  1
}
A =
{
  [1,1] =  1
  [1,2] =  2
}
A =
{
  [1,1] =  1
  [1,2] =  2
  [1,3] =  3
}
There, class of variable  is cell and I should like getting double

Do you have an idea?

Regards,
Le loup

--
Sent from: Octave - Octave - General | Mailing List Archive


"Do you have an idea?" - how about using a struct and its keys as variable names ?


Start from 'help struct' within Octave.

--Sergei.








reply via email to

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