Re: Creating a variable variable name o_O



"Andy Eisenberg" <theorigamist@xxxxxxxxx> wrote in message <h3l9s7$vk$1@xxxxxxxxxxxxxxxxxx>...
"Judy " <sauwen.jl@xxxxxxxxx> wrote in message <h3l8dd$ksj$1@xxxxxxxxxxxxxxxxxx>...
Hi everyone,

I am trying to make a loop to make small chunks of an array instead of a single large array (memory problems).

I am thinking to renaming each chunk name#..so:
Name1
Name2
Name3
so on..

What is the best way to do this?
I tried:
for cnt=1:n,
['Name' cnt]=array
end

However that gives me an error.
??? Error: An array for multiple LHS assignment cannot contain character string.
Should ['Name' cnt] be changed to something else other than a string? If so, in what form?


Thanks for any advice.


Try this:

array=rand(1,10);
for cnt=1:10
eval(sprintf('Name%d=%d',i,array(i)));
end

Whoops. Some sloppy errors here. Try this:


array=rand(1,10);
for i=1:10
eval(sprintf('Name%d=%d;',i,array(i)))
end

% Changes: before I left 'cnt' as the increment in the for loop, even though I
% referenced it as i.
% Also, make sure you have the semicolon inside the regular expression in sprintf.
% Otherwise a semicolon at the end of the line is not enough to prevent the
% variables displaying to the command line.
.



Relevant Pages

  • Re: why does thus cause a segmentation fault?
    ... The semicolon here means that this is a loop ... which does nothing but set ix equal to array size. ... My eyes were glazed over by the sheer error density. ...
    (comp.lang.c)
  • Re: Heres a new quesion about file I/O in Rexx
    ... loop and process all the data in chunks in the array without having ... work on records of different lengths. ...
    (comp.lang.rexx)
  • Re: why does thus cause a segmentation fault?
    ... The semicolon here means that this is a loop ... You now try to set element 10 of an array which has ...
    (comp.lang.c)
  • Heres a new quesion about file I/O in Rexx
    ... What I'm thinking is read the first 1 million records, process those records, clear the array and start over; The catch is I can't read all the data into the array at one point in time. ... Chunking the data into say 1 million records so I can put it in a loop and process all the data in chunks in the array without having to keep track of where I am in the read process and have it continue over an over? ...
    (comp.lang.rexx)
  • Re: Parsing a string into an array?
    ... spliton the semicolon and then loop through the array and use split (on ... Take the second value from that operation and put it in an array (or use it ... I'm using HTTPRequest to download a page of stock prices from ADVFN. ...
    (microsoft.public.excel.programming)