I understand that you want to plot “GNSS” data from a “24x1 cell array” (“TC_NORM”), where each cell represents an hour with a “6x3600” double matrix. You also want to visualize all 32 GPS satellites over a 24-hour period with distinct colors and line styles.
Kindly refer to the following steps to achieve the same:
- Initialize the figure to plot all data in one graph.
- Define colors and line styles. Use 8 colors for groups of 8 satellites and use 4 different line styles (-, --, :, -.) to differentiate them.
- Loop through each hour (1-24). Extract the 6x3600 double matrix from “TC_NORM”{hour} and compute the time range (in seconds) for the current hour.
- Loop through all 32 satellites and assign row indices (modulo 6) to fetch data. Also, assign color and line style based on satellite index.
- Now plot the data and set appropriate plot styling.
You can also go through the below code which implements the above approach:
clc; clear; close all;
% Assume TC_NORM is already loaded as a 24x1 cell array
colors = {'y', 'm', 'c', 'r', 'g', 'b', 'w', 'k'};
lineStyles = {'-', '--', ':', '-.'};
figure;
hold on;
total_seconds = 24 * 3600; % Total seconds in a day
yticks(1:32) = 1:32;
for hour = 1:24
if isempty(TC_NORM{hour})
continue;
end
data = TC_NORM{hour}; % 6 x 3600 matrix per hour
start_time = (hour - 1) * 3600; % Starting second for the hour
for sv = 1:32
row = mod(sv-1,6) + 1; % Select row in 6x3600 matrix
time_values = start_time + (1:3600);
color_index = mod(sv-1, 8) + 1;
line_index = floor((sv-1) / 8) + 1;
plot(time_values, data(row, :), 'Color', colors{color_index}, 'LineStyle', lineStyles{line_index});
end
end
ylabel('Satellite PRN');
xlabel('Time (seconds of the day)');
title('GNSS Output Plot');
ylim([1, 32]);
set(gca, 'YTick', 1:32);
grid on;
hold off;
For further reference on MATLAB’s plotting functions, kindly refer to:
Cheers & Happy Coding!
