MATLAB Answers

remove zeros from a 15x300 matrix and find the median

조회 수: 1(최근 30일)
fadams18
fadams18 11 Feb 2020
댓글: Image Analyst 11 Feb 2020
when I run the code below I get 15x301 matrix AS_V with some receding zeroes
for i=1:15
load(['output/NeNMF_V_', int2str(i), '.mat'], 'AS' );
AS_V(i,:)= AS;
end
I would like to remove these zeros and take take the median of each row so that, I will now have 15x1 matrix

  댓글 수: 0

로그인 to comment.

답변(1개)

Rik
Rik 11 Feb 2020
You can use this inside your loop.
AS_V(i)= median(AS(AS~=0));

  댓글 수: 3

fadams18
fadams18 11 Feb 2020
for some reason one of the median is NaN. why is that so. I only want to remove receding zeros in the original matrix all other entries are nonzeros and non-NaNs
Rik
Rik 11 Feb 2020
Can you confirm find(isnan(AS)) returns an empty array?
Image Analyst
Image Analyst 11 Feb 2020
Attach the mat file where that happens with the paper clip icon if you still have trouble.

로그인 to comment.

이 질문에 답변하려면 로그인을(를) 수행하십시오.

제품


Translated by