How to get the rows and columns from a matrix which do not fall into particular criteria?
2 次查看(过去 30 天)
显示 更早的评论
Hello,
My data comprises of a matrix.
% Data1 = 25000 x 30 double
After running some lines of code I got my Data2 (from Data1 using logical indexing etc) which is now
% Data2 = 10000 x 30 double
However I also want to do some statistics on the rest 15000 x 30 dataset. I guess it's quite simple but I can't figure out how to get this 15000 x 30 matrix from Data1. After doing logical indexing etc I got Data2, how to get the remaining matrix which do not fall into my particular criteria for Data2 i.e, 15000x30? Thank you
0 个评论
采纳的回答
Dyuman Joshi
2023-3-16
Use negation on the logical indexing -
x = 0:0.01:10;
y = [sin(x); cos(x)];
%Get columns of y in which
%first row is less than or equal to -0.25
idx = y(1,:)<=-0.25;
data1 = y(:,idx)
%Get the data which doesn't fall into that category
data = y(:,~idx)
4 个评论
Dyuman Joshi
2023-3-16
Lat=Data1(:,1);
Lon=Data1(:,2);
land = shaperead('landareas', 'UseGeoCoords', true);
land_flags = zeros(length(Lat),1);
for i = 1 : size(land,1)
Lat_land = land(i).Lat;
Lon_land = land(i).Lon;
in1 = inpolygon(Lat(:),Lon(:),Lat_land,Lon_land);
land_flags = land_flags + in1;
end
idx = land_flags == 0:
Data1 = Data1(idx,:);
Data2 = real(Data1); % 10000x30
Data3 = Data1(~idx,:)
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Logical 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!