1 how to extract cols and rows from a matrix,2,how to find a value the vector close to ,

1 view (last 30 days)
data size is MxN ,assume only one nan in data i need remaining part of data ,
if true
remain1 = data;
remain2= data(nanrows,:);
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

Accepted Answer

Salaheddin Hosseinzadeh
Salaheddin Hosseinzadeh on 14 Sep 2014
Hi Roger,
I don't think if you needed to assign the data to remain1 remain2 and ... you could do anything you wanted to do with data.
q2- You may wanna use histogram (hist) to determine the most frequent number in your data, which will be 2 probably or you may take an average of that specific bean which gives you more accurate measure. Read more about hist
doc hist
Or you may take an average if that satisfies you.
Good Luck!

More Answers (1)

Image Analyst
Image Analyst on 15 Sep 2014
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.


Community Treasure Hunt

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

Start Hunting!