I have a column vector and I am trying to write a function implementing somehow a variable windowing function. Meaning that i want to choose one row and skip a number of rows (this is the variable part), but not only skipping, i have also to set the value of one of the columns in the skipped row equal to the chosen row before them of the same column. The column is:
----------
P1
----------
P2
----------
P3
----------
P4
----------
So the goal is to create a new column with P1 P1 P3 P3 P4 P4 ... The variable part means by changing a variable in the function, it is possible to create a new column with P1 P1 P1 P4 P4 P4 P7 P7 P7 ...
I tired something like this:( to implement the first case)
% column vector containing P values a
a ;
delay = 0;
% f parameter to enter the delay processing
f = 2;
r = length(a);
i = 1;
while(i <= r)
if(mod(i, f) == 0)
for j = 0 : delay
a(i + j) = a(i - 1);
end
i = i + delay + 1;
else
i = i + 1;
end
end
I think the problem is in using the MOD function or choosing the values of f.
any help is appreciated.