Clear Filters
Clear Filters

Getting max and min in data from 1 hour every 5 mins

2 views (last 30 days)
Hi, I've got a code that gets me the lat and lon of each message of an hour, gets me the distance of each point and saves the max100. Every lat lon has a time arrival, how could I do the same but instead of everyr hour(one time per file) do it every 5 or 10 mins(I have the variable time already that has the minute and second of each message, so it would be divide the code for every 5 or 10 mins)
flashpode on 25 Apr 2022
yeah so first thing the minut and the second of the message is in the name of the message so I extracted it the following way:
AIS1 = importfileAIS(thisfile1);
AIS1(strlength(AIS1) < 15) = [];
msg_AIS1 = regexp(AIS1, '.*(?=\d{4}$)', 'match', 'once');
t1 = regexp(AIS1, '\d{4}$', 'match', 'once'); %
then I code the lat and lon and calculate all the distances of the hour
lat1 = [];
lon1 = [];
for i=1:1:N
seq1 = AIS1(i);
if linia(13)=='A' && linia(15)=='1'
sequencia = ais_to_bit(linia(15:44));
longitud = bin2dec(num2str(s_longitud))/600000; lon1 = [lon1, longitud];
latitud = bin2dec(num2str(s_latitud))/600000; lat1 = [lat1, latitud];
pos_lat = 1:numel(lat1); value_lat = lat1(lat1>50); index1 = pos_lat(lat1>50);
lat1(index1) = [];lon1(index1) = [];
pos_lon = 1:numel(lon1); value_lon = lon1(lon1>3); index2 = pos_lon(lon1>3);
lat1(index2) = []; lon1(index2) = [];
catch ME
%%Calculamos las distancias Max #1 y #100
NumLat1 = numel(lat1);
for i = 1:1:NumLat1
loc1 = [lat1(i),lon1(i)]; loc2 = [41.3828 2.1857];
[~,Dist] = haversine(loc1,loc2);
Total_Dist{i} = Dist;
The point is that I want to get the highest distances every 5 or 10 mins

Sign in to comment.

Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!