HbO_index = find(xyz1 > 7.5);%link the index with the HbO table and eliminate the bad channels
HbO_good_channel = HbO;
% for i = 1 : size(HbO,2)
for l = 1 : length(HbO_index)
k = HbO_index(l);
HbO_good_channel(:,k) = [];
end
% end
HbO_index is matrix containing values which are basically index of HbO_good_channels which i want to remove.
Only the first column from HbO_good_channels it removing properly rest its removing one index prior to what is actually mentioned, it something to do with my logic. help me out please.
thank you

댓글 수: 2

madhan ravi
madhan ravi 2019년 9월 3일
Attach your data as .mat file.
CalebJones
CalebJones 2019년 9월 3일
편집: CalebJones 2019년 9월 3일
I have attached the files below madhan ravi

댓글을 달려면 로그인하십시오.

 채택된 답변

David
David 2019년 9월 3일

0 개 추천

The problem is that in your for-loop you delete the l-th column. Thereby all the indecies of the following columns change (are reduced by one). This happens in each iteration of the for-loop. If you want to remove columns "a, b, c, d" with your code you will actually remove columns "a, b+1, c+2, d+3".
You can solve your problem by starting the for loop on the end of "HBO_index" or without a for-loop:
HbO_good_channel = HbO
HbO_good_channel(:,find(xyz1 > 7.5)) = [];

댓글 수: 3

CalebJones
CalebJones 2019년 9월 3일
Thank You man .... David
You could also remove the "find" and use logical indexing for better performance:
HbO_good_channel = HbO
HbO_good_channel(:,xyz1 > 7.5) = [];
CalebJones
CalebJones 2019년 9월 3일
Sure thank you David

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Matrix Indexing에 대해 자세히 알아보기

질문:

2019년 9월 3일

댓글:

2019년 9월 3일

Community Treasure Hunt

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

Start Hunting!

Translated by