How to get the rows and columns from a matrix which do not fall into particular criteria?
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Zhou Ci
el 16 de Mzo. de 2023
Comentada: Dyuman Joshi
el 16 de Mzo. de 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 comentarios
Respuesta aceptada
Dyuman Joshi
el 16 de Mzo. de 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 comentarios
Dyuman Joshi
el 16 de Mzo. de 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,:)
Más respuestas (0)
Ver también
Categorías
Más información sobre Logical en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!