From: frank millo on
Hello All,
Problem:
Need to extract values ranging from index 1 to 5 and write
it into a new variable.
Then take index 6 to 10 and write it into the next variable....
Basically extract a range of 5 indices from start to end and write each into
a variable.
Question: do you use a loop or some sort of index mechanism?

Thanks
FM
From: Matt Fig on
Extract the values from what? A structure? A cell array? A textfile?

Perhaps a small example which captures the relevant features of your problem would be appropriate.
From: John D'Errico on
"frank millo" <frank.millo(a)gmail.com> wrote in message <hpm212$pt3$1(a)fred.mathworks.com>...
> Hello All,
> Problem:
> Need to extract values ranging from index 1 to 5 and write
> it into a new variable.
> Then take index 6 to 10 and write it into the next variable....
> Basically extract a range of 5 indices from start to end and write each into
> a variable.
> Question: do you use a loop or some sort of index mechanism?
>
> Thanks
> FM

You DON'T do it at all.

Learn to use cell arrays, so you can assign all of
these "variables" into one single cell array with the
function mat2cell.

John
From: frank millo on
"Matt Fig" <spamanon(a)yahoo.com> wrote in message <hpm4ur$6p3$1(a)fred.mathworks.com>...
> Extract the values from what? A structure? A cell array? A textfile?
>
> Perhaps a small example which captures the relevant features of your problem would be appropriate.

Matt,
you right, this example is not very descriptive. Maybe this helps.
source data is a column vector, e.g
data = [1:15]'
result should be
t1 = data(1:3);
t2 = data(4:6);
t3 = data(7....

I just wanted to test the mechanism, the actual data is well over 10e6 values.
fm
From: Matt Fig on
In that case, I would not do what you are thinking of doing. Do as John suggested, use a cell array. You can even use MAT2CELL to break it up as you wish.