Hi,
It is my understanding that, you are trying to plot Ne vs MLT for each orbital pass of SWARM satellite. But the passes are not correctly separated.
In the provided code, the condition ‘(t_minutes(i) - t_minutes(i-1)) > T*1.5’ is used to determine the end of one pass and the start of the next pass. However, it does not accurately capture the transitions between passes, leading to incorrect separation.
Instead of this, look for the points where the MLT values wrap around from high to low or vice versa using the sign of gradient of the MLT, as this indicates the start or end of a new orbit pass.
Please refer to the below modified code:
% Identify the start and end times for each orbit pass
pass_num = 1;
start_index = 1;
grad_mlt = gradient(MLT);
for i = 2:length(grad_mlt)
if sign(grad_mlt(i)) ~= sign(grad_mlt(i-1)) % check for sign change
end_index = i-1;
ne = Ne(start_index:end_index);
mlt_pass = MLT(start_index:end_index);
% Plot the data for this pass
figure
plot(mlt_pass, ne)
xlabel('MLT')
ylabel('Ne')
title(['Orbit Pass ', num2str(pass_num)])
pass_num = pass_num + 1;
start_index = i;
end
end
% Extract the data for the last orbit pass
end_index = length(t_minutes);
ne = Ne(start_index:end_index);
mlt_pass = MLT(start_index:end_index);
% Plot the data for the last pass
figure
plot(mlt_pass, ne)
xlabel('MLT')
ylabel('Ne')
title(['Orbit Pass ', num2str(pass_num)])
For more information on ‘gradient’ function, please refer to the below documentation link:
For more information on ‘sign’ function, please refer to the below documentation link:
Hope this helps you resolve the query!