|
| 1 | +function [ delay ] = Create_delay(position_cbf,time, inc) |
| 2 | +% Calculate delay between LEOs and facilities |
| 3 | +% input: |
| 4 | +% position_cbf: used to connect to STK |
| 5 | +% delay: two-dimensional matrix, delay(i,j) denotes |
| 6 | + global No_fac No_leo constellation; |
| 7 | + load('Num_leo.mat') |
| 8 | + load('Num_fac.mat'); |
| 9 | + distance = zeros(No_fac+No_leo,No_fac+No_leo); |
| 10 | + delay = zeros(No_fac+No_leo,No_fac+No_leo); |
| 11 | + %calculate the distance and delay between leo and others(include leo) |
| 12 | + no = No_leo/leo_plane; |
| 13 | + for i=1:leo_plane |
| 14 | + for j=1:no |
| 15 | + cur_leo = (i-1)*no+j; |
| 16 | + % if the current satellite is already the last one in the orbit |
| 17 | + %, its up one is the first one |
| 18 | + if j ~= no |
| 19 | + up_leo = (i-1)*no+j+1; |
| 20 | + else |
| 21 | + up_leo = (i-1)*no+1; |
| 22 | + end |
| 23 | + distance(cur_leo,up_leo) = sqrt((position_cbf{cur_leo,1}(1,time) - position_cbf{up_leo,1}(1,time))^2 + (position_cbf{cur_leo,1}(2,time) - position_cbf{up_leo,1}(2,time))^2 + (position_cbf{cur_leo,1}(3,time) - position_cbf{up_leo,1}(3,time))^2); |
| 24 | + distance(up_leo,cur_leo) = distance(cur_leo,up_leo); |
| 25 | + % use light speed |
| 26 | + delay(cur_leo,up_leo) = distance(cur_leo,up_leo) / (3 * 10^5); |
| 27 | + delay(up_leo,cur_leo) = delay(cur_leo,up_leo); |
| 28 | + if i ~= leo_plane |
| 29 | + right_leo = i*no+j; |
| 30 | + |
| 31 | + else |
| 32 | + if inc > 80 && inc < 100 |
| 33 | + continue; |
| 34 | + else |
| 35 | + right_leo = j; |
| 36 | + end |
| 37 | + end |
| 38 | + distance(cur_leo,right_leo) = sqrt((position_cbf{cur_leo,1}(1,time) - position_cbf{right_leo,1}(1,time))^2 + (position_cbf{cur_leo,1}(2,time) - position_cbf{right_leo,1}(2,time))^2 + (position_cbf{cur_leo,1}(3,time) - position_cbf{right_leo,1}(3,time))^2); |
| 39 | + distance(right_leo,cur_leo) = distance(cur_leo,right_leo); |
| 40 | + delay(cur_leo,right_leo) = distance(cur_leo,right_leo) / (3 * 10^5); |
| 41 | + delay(right_leo,cur_leo) = delay(cur_leo,right_leo); |
| 42 | + end |
| 43 | + end |
| 44 | + % each satellite will always be able to talk with the ground station |
| 45 | + for i = 1:No_leo |
| 46 | + for j = No_leo + 1:No_fac+No_leo |
| 47 | + distance(i,j) = sqrt((position_cbf{i,1}(1,time) - position_cbf{j,1}(1,time))^2 + (position_cbf{i,1}(2,time) - position_cbf{j,1}(2,time))^2 + (position_cbf{i,1}(3,time) - position_cbf{j,1}(3,time))^2); |
| 48 | + distance(j,i) = distance(i,j); |
| 49 | + delay(i,j) = distance(i,j) / (3 * 10^5); |
| 50 | + delay(j,i) = delay(i,j); |
| 51 | + end |
| 52 | + end |
| 53 | + filename = [constellation '\delay\']; |
| 54 | + filename = strcat(filename,num2str(time)); |
| 55 | + filename = strcat(filename,'.mat'); |
| 56 | + save(filename,'delay') |
| 57 | +end |
| 58 | + |
0 commit comments