Untitled
unknown
matlab
a year ago
1.7 kB
2
Indexable
Never
clc; clear; % Read the data using importdata data = importdata('iss_p_v2.txt'); % Preallocate a cell array to store the separated values separatedData = cell(numel(data), 7); % Iterate through the imported data, split by spaces, and store in the separatedData cell array for i = 1:numel(data) row = data{i}; % Access each row values = strsplit(row); % Split the row by spaces separatedData(i, :) = values; % Store the separated values in the new cell array end Time = separatedData(:,1); Time = datetime(Time, 'InputFormat', 'yyyy-MM-dd''T''HH:mm:ss.SSS'); separatedData(:, 1) = []; X = separatedData(:,1); Y = separatedData(:,2); Z = separatedData(:,3); position = [X, Y, Z]; position = str2double(position); VX = separatedData(:,4); VY = separatedData(:,5); VZ = separatedData(:,6); velocity = [X, Y, Z]; velocity = str2double(velocity); % positionData = timetable(position,'TimeStep',seconds()); % velocityData = timetable(velocity,'TimeStep',seconds()); num_rows = size(position, 1); % Get the number of rows r_eci = zeros(num_rows, 3); % Preallocate r_eci with the same number of rows v_eci = zeros(num_rows, 3); % Preallocate v_eci with the same number of rows utc = [2021 11 22 12 0 0]; for i = 1:num_rows [r_eci(i, :), v_eci(i, :)] = eci2ecef(utc, position(i, :), velocity(i, :)); end positionData = timetable(Time,r_eci); velocityData = timetable(Time,v_eci); % startTime = datetime(2021,11,22,12,0,0); % stopTime = startTime + days(30); %sampleTime = 60; % seconds sc = satelliteScenario; ISS = satellite(sc,positionData,velocityData,"CoordinateFrame","ecef"); v = satelliteScenarioViewer(sc); play(sc);