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!