[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Naming variables using existing variables....
From: |
Przemek Klosowski |
Subject: |
Re: Naming variables using existing variables.... |
Date: |
Mon, 28 Feb 2011 11:29:16 -0500 |
User-agent: |
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.13) Gecko/20101209 Fedora/3.1.7-0.35.b3pre.fc14 Lightning/1.0b2 Thunderbird/3.1.7 |
On 02/28/2011 10:41 AM, bleagos wrote:
Thanks for replying so quick. The only problem with this is that I
want my input to be matrices of different size depending on the
local variable. So something like this:
for i=1:n A_i = rand(i,i); end
I think such 'synthetic' variable names almost always are a mistake.
Octave has a perfectly good datatype for this kind of work, the cell array:
for i=1:4
A{i}=rand(i);
end
results in A =
{
[1,1] = 0.61921
[1,2] =
0.13984 0.64332
0.55874 0.79659
[1,3] =
0.85950 0.75172 0.23826
0.87920 0.39471 0.83086
0.74039 0.41796 0.25512
[1,4] =
0.091380 0.514551 0.901517 0.451026
0.346724 0.840009 0.057729 0.225127
0.625270 0.867836 0.830498 0.292810
0.923174 0.948555 0.781887 0.082019
}
Re: Solved: Naming variables using existing variables...., bleagos, 2011/02/28