Monday 15 September 2014

matrix - Looping through measurement data then create vectors in Matlab -



matrix - Looping through measurement data then create vectors in Matlab -

i have looked @ previous posts can't find satisfactory solution case yet. new matlab , have input/output device info have arranged column vectors, need loop equal sized windows through whole datafile creating same sized vectors @ each instance. info has 600 columns illustration table below. sorry doesnt best won't allow me edit properly: vectors i2, i3, i4,...,i600 built same way i1.

data type ____ columns 1 … 600

input

0.20 0.37 0.21 -0.04 … -0.06 0.01 0.31 0.17 ...

output

0.34 -0.08 0.59 -0.04 … 0.11 0.06 0.72 0.18 … -0.27 0.09 0.59 0.03 …

each vector have 14 elements data. i1=[0.20; -0.06; 0.37; 0.01; 0.21; 0.31; -0.04; 0.17;...], i2=[0.37; 0.01; 0.21; 0.31; -0.04; 0.17;...], i3=[0.21; 0.31; -0.04; 0.17;...],..to i600. means vector i1 built input info values in columns 1-7 listed, , i2 contain columns 2-8, while i3 columns 3-9 , forth. can see, hence trying create info forming 'overlapping' 14x1 input vectors. outputs ie o1, o2,..will formed in same way vectors 21x1 in size, how build these vectors data? stuck please help,

thank in advance :) tee

% create 2x600 array random entries. q = rand( 2, 600 ); % offset origin of each % set want extract above % array. subtract 7 600 since % pulling off 14 elements @ time , % have stop @ 7th-to-last column. offsets = 2 * ( 0 : 600 - 7 ); % these indices of elements want % organized column. have % offset numbers 1 thorugh 14 % amounts found above. v = (1:14)'; inds = repmat( v, 1, length( offsets ) ) + repmat( offsets, length(v), 1 ); % can pull off overlapping submatrices want. c = q(inds);

here illustration output:

>> q(:,1:10) ans = 0.8147 0.1270 0.6324 0.2785 0.9575 0.1576 0.9572 0.8003 0.4218 0.7922 0.9058 0.9134 0.0975 0.5469 0.9649 0.9706 0.4854 0.1419 0.9157 0.9595 >> c(:,1:2) ans = 0.8147 0.1270 0.9058 0.9134 0.1270 0.6324 0.9134 0.0975 0.6324 0.2785 0.0975 0.5469 0.2785 0.9575 0.5469 0.9649 0.9575 0.1576 0.9649 0.9706 0.1576 0.9572 0.9706 0.4854 0.9572 0.8003 0.4854 0.1419

you can see first row of c first 7 columns of q, while sec column columns 2-8 of q.

matlab matrix vector

No comments:

Post a Comment