For Loop calculating too slowly
Mostrar comentarios más antiguos
The code I am running now takes way too long to go through all the iterations to calculate the direction cosine matrix (DCM) for each second, minute, hour. I am using the function 'dcmeci2ecef' in the aerospace toolbox to calculate a DCM that I need to continue. I know there should be better ways to write this that does not take a long time to go through each iteration and display each individual DCM through the course of 24 hours. Any ideas?
for i = 0:24 % hours
for j = 0:60 % minutes in a hour
for k = 0:60 % seconds in a min
dcm_FI = dcmeci2ecef('IAU-2000/2006',[2019 9 30 i j k]);
end
end
end
Respuestas (1)
darova
el 2 de Oct. de 2019
Maybe try
[S,M,H] = ndgrid(0:60, 0:60, 0:24);
data1 = repmat([2019 9 30],[length(S(:)) 1]);
data2 = [H(:) M(:) S(:)];
data = [data1 data2];
dcm_FI = dcmeci2ecef('IAU-2000/2006', data)
1 comentario
Note that length(S(:)) is simply numel(S).
A simpler way to create that data matrix would be:
data = datevec(datetime(2019, 9, 30) + seconds(0:60*60*24-1)')
Categorías
Más información sobre Axes Transformations en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!