On Thu, Jun 7, 2012 at 6:23 AM, stn
<address@hidden> wrote:
2012/5/31 Doug Stewart
<address@hidden>
Is your input really an English statement ?
Is the English part always the same and can be ignored or does the parser have to look at these words and decide what to do?
@Doug
Hi Doug,
sorry, my bad for not making it clear.
The english statement was not meant to be input into octave. It was meant to describe to the list (in english) what the question is about.
The question I have is this: what would be an efficient octave-syntax to express the english statement "give me 2 groups length 3, 1 group length 6, 1 group length 2, counting from 1 to last, (whatever last may be)".
The point is that this definition would change all the time. So group 3 (length=6) would in the next run be length=7, implying that groups 4:end would have to shifted by one item. Or a third group with length 3 may be added at the beginning. The definition would then change to to "give me 3 groups length 3 ..."
In each case the automatic implication is to count from 1 to last number necessary so there is no need to explicitely state the increment in the definition. Like [ 1:10 ] implies "increment=1"
@Sergej
Hi Sergej, your suggestion would work and is similar to the solution I gave in the first post.
The problems would begin once you try to change the definition. For example if you want to change the length of the second group (4:6 in your example to 4:7) then you have to manually change every group that follows.
So if testing different group-lengths and -combinations is what the whole thing is about then you become really busy changing group-definitions. Do that 20 times a day (or 200 times in my case) and you never get around to the actual calculations. And don't even think about how many errors you would make on the way, like leave out numbers or assign numbers to two different groups.
Regards
Stefan
There are many ways of doing this, so here is one suggestion!!!
Make an index1.txt file that looks like this
etc.
and make a script file (ind.m) that is this:
ind1=load("index1.txt")
data1=1:100;
count=1;
for k=1:length(ind1)
for m= 1:ind1(k,1)
for p=1:ind1(k,2)
%%****************************
% this is for diplay only
a(p)=data1(count);
%%****************************
count=count+1;
endfor
%%****************************
% this is for diplay only
a
clear("a")
%%****************************
endfor
endfor
From Octave just run ind and see the result.
Since I don't know your data you would have to replace my display parts with your code.
HTH
Doug
PS this can probably be vectorized but I think this should be clearer(walk before you run!)