0

I'm new to octave and if this as been asked and answered then I'm sorry but I have no idea what the phrase is for what I'm looking for.

I trying to remove the DC component from a large matrix, but in chunks as I need to do calculations on each chuck.

What I got so far

r = dlmread('test.csv',';',0,0);
x = r(:,2);
y = r(:,3); % we work on the 3rd column

d = 1
while d <= (length(y) - 256)
    e = y(d:d+256);
    avg = sum(e) / length(e);
    k(d:d+256) = e - avg;      % this is the part I need help with, how to get the chunk with the right value into the matrix
    d += 256;
endwhile

% to check the result I like to see it
plot(x, k, '.');

if I change the line into:

k(d:d+256) = e - 1024;

it works perfectly. I know there is something like an element-wise operation, but if I use e .- avg I get this:

warning: the '.-' operator was deprecated in version 7

and it still doesn't do what I expect.

I must be missing something, any suggestions?

GNU Octave, version 7.2.0 on Linux(Manjaro).

Robert
  • 37
  • 3
  • It is unclear from the question what the problem is. It is always best to show your output and the expected output, so we can see why you think the code is wrong. I see from your answer that there is not really a problem. I suggest you delete the question. – Cris Luengo Aug 14 '22 at 19:07

2 Answers2

0

Never mind the code works as expected. The result (K) got corrupted because the chosen chunk size was too small for my signal. Changing 256 to 4096 got me a better result.

Robert
  • 37
  • 3
0

+ and - are always element-wise. Beware that d:d+256 are 257 elements, not 256. So if then you increment d by 256, you have one overlaying point.

S. Gougeon
  • 791
  • 3
  • 16