Element-by element wise matrix addition of pieces of a matrix
Show older comments
Hi, I apologize if this question is very simple, I am new to MATLAB! I need to take a vector that is 1024 elements, and sum the first 256 elements , ie 1+257, 2+258, etc. I keep getting an error that matrix dimensions don't agree, but I don't understand since I am adding 256 elements each time. I need the vector xx2cyc to be (256,1) when it is done.
Here is my code:
Navg = 10;
jj = 1;
jjj = 256;
overLapPercent = 0.5;
Overlap = 1024 * overLapPercent;
k = 1;
xx2cyc = zeros(256,1);
for ii = 1:Navg
%Overlap processing
ff = y1(k:k+1024-1);
xx2 = y2(k:k+1024-1);
ff = hann(1024).*ff'; %Window data
xx2 = hann(1024).*xx2';
%Cyclic Averaging, for 4 cyclic averages
xx2cyc = xx2(jj:jjj) + xx2(jjj:2*jjj); + xx2(2*jjj:3*jjj) + xx2(3*jjj:4*jjj);
xx2cyc= xx2cyc./4;
k=k+Overlap;
end
Accepted Answer
More Answers (0)
Categories
Find more on Matrix Indexing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!