1 how to extract cols and rows from a matrix,2,how to find a value the vector close to ,
이전 댓글 표시
data size is MxN ,assume only one nan in data i need remaining part of data ,
if true
[nanrows,nancols]=find(isnan(data));
remain1 = data;
remain1(:,nancols)=[];
remain1(nanrows,:)=[];
%
remain2= data(nanrows,:);
remain2(1,nancols)=[];
remain3=data(:,nancols);
remain3(nanrows,1)=[];
end
any ways better?
q2: similarly finding a centre of the vector; a=[1 2 2 3 4 2.1 2.2 5] the value may be 2.2 , as the elements close to 2.2 is the most
채택된 답변
추가 답변 (1개)
Image Analyst
2014년 9월 15일
for the first question
m=randi(9, 5,5) % Create sample data
m(4,2:4) = nan % Stick in some nans
% Find non-nan elements.
nonNanData = m(~isnan(m))
For the second question, the "center" as you call it is just the mean, like SH said. If not, explain what you mean.
카테고리
도움말 센터 및 File Exchange에서 Logical에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!