How do I write a statement that will discard any values in an array if they are over a certain value?

2 次查看(过去 30 天)
I want to say that if my height variable is > 1 then not to return the value in my matrix?
  3 个评论
Seth
Seth 2013-5-16
I have a 73 x 1 array and in the column I only want to read in the row if the value is less than 1.. I have imported the file in by writing:
File = xlsread('Group B input.xlsx');
And I now want to say that matlab should only read in the values < 1
José-Luis
José-Luis 2013-5-16
It is easier to import everything to Matlab and then do the processing. Alternatively you could preprocess in Excel if you are more comfortable doing that.

请先登录,再进行评论。

回答(1 个)

Ken Atwell
Ken Atwell 2013-5-16
I think you're looking for logical indexing:
heights = .1:.3:2
heights < 1
heights(heights<1)

类别

Help CenterFile Exchange 中查找有关 Data Type Identification 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by