Filter löschen
Filter löschen

How to select particular rows from a large matrix ?

473 Ansichten (letzte 30 Tage)
srinivasarao tanniru
srinivasarao tanniru am 23 Jul. 2013
Beantwortet: Milan Vasiç am 11 Aug. 2020
I have been working with the satellite data. So I have exported some data into matlab which contains nearly 16,000 rows and 6 columns. The first 2 columns are latitude and longitude and next columns contain various data fields like CO2 etc. what should I do to select the data that lies between particular latitude and longitudes. like limits of latitude are 20 to 30 and limits of longitude are 40 to 50.

Akzeptierte Antwort

kjetil87
kjetil87 am 23 Jul. 2013
Bearbeitet: kjetil87 am 23 Jul. 2013
small example: x=zeros(6,6); x(:)=1:numel(x)
x =
1 7 13 19 25 31
2 8 14 20 26 32
3 9 15 21 27 33
4 10 16 22 28 34
5 11 17 23 29 35
6 12 18 24 30 36
% now select the row(s) that have first column number between 3 and 5
x(x(:,1)>2 & x(:,1)<6 , :)
% if you want to add constraints on column 2 aswell:
x( x(:,1)>2 & x(:,1)<6 & x(:,2)>8 & x(:,2)<11 , :)

Weitere Antworten (2)

suresh s
suresh s am 23 Jul. 2013
yes, we can do in Matlab
Example:
>> a=magic(4)
a =
16 2 3 13
5 11 10 8
9 7 6 12
4 14 15 1
>> a(2:4,2:4)
ans =
11 10 8
7 6 12
14 15 1
ans is row from 2 to 4 and column from 2 to 4
NOTE: In matlab Matrix always start from 1

Milan Vasiç
Milan Vasiç am 11 Aug. 2020
I want to form a table like this:
I wrote the code:
u = 8;
z1 = 13;
FI_K0 = 45;
for b = 0:10:180
fprintf('%5d', b)
for j=1:u
FI_K (j) = FI_K0 + (j - 1) * (360. / u) - (b / z1)
end
end
In Command Window I get the following results:
0
FI_K = 45
FI_K = 45 90
FI_K = 45 90 135
FI_K = 45 90 135 180
FI_K = 45 90 135 180 225
FI_K = 45 90 135 180 225 270
FI_K = 45 90 135 180 225 270 315
FI_K = 45 90 135 180 225 270 315 360
10
FI_K = 44.2308 90.0000 135.0000 180.0000 225.0000 270.0000 315.0000 360.0000
FI_K = 44.2308 89.2308 135.0000 180.0000 225.0000 270.0000 315.0000 360.0000
FI_K = 44.2308 89.2308 134.2308 180.0000 225.0000 270.0000 315.0000 360.0000
FI_K = 44.2308 89.2308 134.2308 179.2308 225.0000 270.0000 315.0000 360.0000
FI_K = 44.2308 89.2308 134.2308 179.2308 224.2308 270.0000 315.0000 360.0000
FI_K = 44.2308 89.2308 134.2308 179.2308 224.2308 269.2308 315.0000 360.0000
FI_K = 44.2308 89.2308 134.2308 179.2308 224.2308 269.2308 314.2308 360.0000
FI_K = 44.2308 89.2308 134.2308 179.2308 224.2308 269.2308 314.2308 359.2308
20
FI_K = 43.4615 89.2308 134.2308 179.2308 224.2308 269.2308 314.2308 359.2308
FI_K = 43.4615 88.4615 134.2308 179.2308 224.2308 269.2308 314.2308 359.2308
FI_K = 43.4615 88.4615 133.4615 179.2308 224.2308 269.2308 314.2308 359.2308
FI_K = 43.4615 88.4615 133.4615 178.4615 224.2308 269.2308 314.2308 359.2308
FI_K = 43.4615 88.4615 133.4615 178.4615 223.4615 269.2308 314.2308 359.2308
FI_K = 43.4615 88.4615 133.4615 178.4615 223.4615 268.4615 314.2308 359.2308
FI_K = 43.4615 88.4615 133.4615 178.4615 223.4615 268.4615 313.4615 359.2308
FI_K = 43.4615 88.4615 133.4615 178.4615 223.4615 268.4615 313.4615 358.4615
I need the following result:
0
FI_K = 45 90 135 180 225 270 315 360
10
FI_K = 44.2308 89.2308 134.2308 179.2308 224.2308 269.2308 314.2308 359.2308
20
FI_K = 43.4615 88.4615 133.4615 178.4615 223.4615 268.4615 313.4615 358.4615
How do I do this?

Kategorien

Mehr zu CubeSat and Satellites 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!

Translated by