for_sashka

mail@pastecode.io avatar
unknown
matlab
6 months ago
1.3 kB
3
Indexable
Never
%% Reading almanac
[almanac, tParameters]= ReadGPSAlmanac();

%% Almanac of one satellite
number = input ('number from 1 to 32:');
for i = 1:11
    disp(almanac(i, number));
end 

%% Almanac of four random satellites
r = randi  (32, [1,4]);
for j = 1:4
    massive(:,1,i) = almanac(:, r(j));
end
massive = squeeze(massive);

%% ECC > 0.01
index = almanac (1,:) >= 0.01;
if ~(index)
    disp('not');
else
    index = almanac(11, index);
    disp(index);
end

%% Almanac time
alTime(1, 1) = almanac(2,1);
alTime(1, 2) = tParameters(1,1);

%% User time
fid = fopen('utcTime.txt', 'r');
utcDate = fscanf(fid,'%c');
fclose(fid);
timeVec = datetime(utcDate,'InputFormat','dd/MM/uuuu HH:mm:ss');
save ('utc.mat', 'timeVec');
[weekGps, tow] = UtcToGps(timeVec);
usTime(1,1) = tow;
usTime(1, 2) = weekGps;

%% Diff time
LM(1, :) = logical(alTime(1, :) == usTime(1, :));
CM(1, :) = alTime(1, :) - usTime (1, :);

%% Mean motion calculation
Mk(1, :) = almanac(8, :);
Mk(2, :) = almanac(1, :);
Mk(3, :) = almanac(7, :);
Mk(4, :) = almanac(8, :);

Mk(3, :) = [];
Mk(2, :) = [];
Mk(1, :) = [];

%% Orbit inclination
Sr = 0;
for i = 1 : 32
    Sr = Sr + Mk(1, i);
end
Sr = Sr / 32;
SrM = mean(Mk, 'all');