From: Andy on 13 Aug 2010 14:48 But that's just silly. You've used eval in a loop to create the separate variables, only to use eval again to put them together. But you have them together in the 1400x5 array a to start out with! You could just use: M = <1x7000 double> b = 5; c = 1; a = zeros(1400,5); for k = 1:1400 a(k,:) = M(idx(1,c:b)); b = b+5; c = c+5; d(k,:) = mean(a(k,:)); end Now wherever you had previously used a_n, you should instead use a(n,:). And when you want all of the vectors together, you already have the array a. As a sidenote, I think the entire loop above can be replaced with (I'm not at MATLAB right now, so you may need to fiddle with this): M = <1x7000 double> a = reshape(M,[1400 5]); d = mean(a);
From: Dave400 on 13 Aug 2010 19:33 "Andy " <myfakeemailaddress(a)gmail.com> wrote in message <i4441k$ese$1(a)fred.mathworks.com>... > But that's just silly. You've used eval in a loop to create the separate variables, only to use eval again to put them together. But you have them together in the 1400x5 array a to start out with! You could just use: > > M = <1x7000 double> > > b = 5; > c = 1; > a = zeros(1400,5); > for k = 1:1400 > a(k,:) = M(idx(1,c:b)); > b = b+5; > c = c+5; > d(k,:) = mean(a(k,:)); > end > > Now wherever you had previously used a_n, you should instead use a(n,:). And when you want all of the vectors together, you already have the array a. > > As a sidenote, I think the entire loop above can be replaced with (I'm not at MATLAB right now, so you may need to fiddle with this): > > M = <1x7000 double> > a = reshape(M,[1400 5]); > d = mean(a); Thanks to everyone for there help. I will looking to each of the methods suggested and will plan to be more efficicent in the furture. Cheers DR
First
|
Prev
|
Pages: 1 2 Prev: Limiting current out of a Simpowersystem Controlled voltage Source Next: Deming Regression |