I am trying to avoid using dyanmic variable names for all the good reasons listed:
I have two long series of numbers stored in a single row matrix that I need to compare but in a particular way.
They are sutbley different. I'm ok to compare them but the first step I need to do is giving me a challenge. I need to break each series into groups (the length of which is a variable), take an average of each group, and store the recovered averages in a matrix.
Then I need to compare the results and the differnce is the answer I am looking for.
The bit that has me vexed is how to do this without using a for loop and dynamic named variables. If I try using the index its not having the desoired outcome despite much experimentation. Here a little test version of what I'm trying to do:
mynumberc = 100 * rand(1, 505);
lenny = length(mynumberc);
group_size = 100;
numberofgroups = floor(lenny/group_size);
nextstart = 1;
nextstop = group_size;
groupdata = ;
group_ave = ;
for i = 1:1:numberofgroups
for c = nextstart:1:nextstop
groupdata(c) = mynumberc(c)
nextstart = nextstart + 1
nextstop = nextstop + 1
group_ave(i, end+1) = mean (groupdata)
i = i + 1;
%remove leading zero element
group_ave = group_ave (2:end)
In this example I'd want the first 500 values of mynumberc to be split into 5 100 value chunks, each chunk averaged and then put in an array of averages called group_ave. The actual use of this will be at much bigger scale which is why I want to avoid dynamically named variables.
Any advice welcome....