How to get the rows and columns from a matrix which do not fall into particular criteria?
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Zhou Ci
am 16 Mär. 2023
Kommentiert: Dyuman Joshi
am 16 Mär. 2023
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 Kommentare
Akzeptierte Antwort
Dyuman Joshi
am 16 Mär. 2023
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 Kommentare
Dyuman Joshi
am 16 Mär. 2023
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,:)
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Logical finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!