필터 지우기
필터 지우기

I have this error msg (Matrix index is out of range for deletion. Error in tray1 (line 31) x1(:,rows) = []; ) what is the problem ????

조회 수: 1 (최근 30일)
[rows, columns] = size(x1); for col = 1 : columns sum = 0; for row = 1 : rows % Now get the mean over all values in this column. columnMeans(col) = sum / rows; if columnMeans(col)> avgcut columnMeans(col)< avgcut x1(:,col) = []; end end end

채택된 답변

alice
alice 2017년 7월 5일
You are deleting columns of your matrix x1 in the loop, so its size has changed (moreover, you skip some columns).
To avoid this, you can store the index of the column you want to delete in the loop and delete them only when the loop is finished:
colToDelete = [];
[rows, columns] = size(x1);
for col = 1 : columns
sum = 0;
for row = 1 : rows % Now get the mean over all values in this column.
columnMeans(col) = sum / rows;
if columnMeans(col)> avgcut || columnMeans(col)< avgcut
colToDelete = [colToDelete,col];
end
end
end
x1(:,colToDelete) = [];

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Convert Image Type에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by