I used the same code for two different input matrices, In both cases i will call it "the input matrix A"
The first case is a 7000X4
The second case is a 29500X12
I need to split a selected column in windows
and then for each window
i need to calculate the std and store the value inside a std_vals
matrix
I took care to change the value of my input variables.
In the first case my goal was to analyze the 4th column, in the second case my goal was to analyze the 12th column
In the first case the code worked
In the second case the code returned me an error message
I tried to analyze all the steps in the code, but i dind't find the error.
Could you please help me to understand better?
column_length=size(A,1);
Amod= mod(column_length,100);
if Amod~=0
A=A(1:(size(A,1)-Amod),:);
end
newlenght=size(A);
%selected column vector to analyze
columnselected=4;
%window dimension
window_size=200;
%overlap between two windows
overlap=0;
%increment needed
step=window_size - overlap;
%std threshold
soglia=2;
std_vals= NaN(size(A,1),1);
devstd=std(A(:,4));
stdInds=bsxfun(@plus,1:step:(size(A,1)-overlap),(0:(window_size-1)).');
%In the first case size(stdInds)=200X35
%In the second case size(stdInds)=200X148
%In the first case size(repmat(columnselected,size(stdInds))= 200X35
%In the second case size(repmat(columnselected,size(stdInds))= 200X148
%In the first case size(A)=7000X4
%In the second case size(A)=29500X12
std_vals=std(A(sub2ind(size(A),stdInds,repmat(columnselected,size(stdInds)))));
highStdWindows=find(std_vals>soglia);
I am self taught. To understand better my error first i rewrite on a piece of paper the code, then i analyzed every step, and studied the output. I took me more than 4 hours.
I also tried to put in the second case a 7000X12 vector, but the code returned me the same error.