Eliminate rows of cell array outside of a range
Show older comments
>> final2{1}
ans =
-7.001608047186611 5.177463903868721
-6.961013319638841 4.836001516995353
-7.434718451674193 5.161775286393533
-7.291806764176719 4.945616389566389
-7.825126063233940 5.291205007203436
-6.988927204305714 5.113082581858984
-6.849059418431168 4.861214486264909
-5.940365630308799 4.722209572707015
-7.176195913281045 5.017166824644659
What is the command to eliminate all rows if the value of the first column is outside a certain range (say, greater than -6.0 or less than -7.0)? In this case the output would be:
>> final2{1}
ans =
-6.961013319638841 4.836001516995353
-6.988927204305714 5.113082581858984
-6.849059418431168 4.861214486264909
Thanks!
Answers (3)
Youssef Khmou
on 8 May 2013
hi try :
final2{1}(final2{1}>-0.6&final2{1}<-0.7)=[];
Azzi Abdelmalek
on 8 May 2013
a= final2{1}
a(a(:,1)>-6 | a(:,1)<-7,:)=[]
final2{1}=a
Andrei Bobrov
on 8 May 2013
final2{1} = final2{1}(final2{1}(:,1)>-7 & final2{1}(:,1)<-6 ,:)
Categories
Find more on Data Types in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!