Satellite communications toolbox with parallel computing
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I would like to run a script containing functions of Satellite communications toolbox with parallel computing in order to save time,
but something is not right and have no clue what.
if I try to run the following commands on an array of satellites using a parfor loop, the final outcome is that no object in the array is affected by them, as in, all values remain the same.
but if I run the commands in a for loop then everything changes as it should.
startTime = datetime(2021,12,10,18,27,57); % 10 December 2021, 6:27:57 PM UTC
stopTime = startTime + hours(3); % 10 December 2021, 9:27:57 PM UTC
sampleTime = 60; % Seconds
sc = satelliteScenario(startTime,stopTime,sampleTime,"AutoSimulate",false)
sat = satellite(sc,"largeConstellation.tle");
numSatellites = numel(sat);
gainToNoiseTemperatureRatio1 = 5; % dB/K
systemLoss1 = 3;
TxMountingLocation = [0;0;1];
RxMountingLocation = [0;0;1];
frequency1 = 27e9; % Hz
%% power between 19 and 26 dBW
power1 = 19+(26-19)*rand(numSatellites,1); % dBW
%% bitRate between 16 and 27 Mbps
bitRate1 = 16 + (27-16)*rand(numSatellites,1); % Mbps
parfor SatNum = 1:15
gimbalrxSat = gimbal(sat(SatNum),"MountingLocation",[0;-1;2]);
gimbaltxSat = gimbal(sat(SatNum),"MountingLocation",[0;1;2]);
rxSat1 = receiver(gimbalrxSat,"Name",'Satellite Receiver',"GainToNoiseTemperatureRatio" ...
,gainToNoiseTemperatureRatio1,"SystemLoss",systemLoss1,"MountingLocation",RxMountingLocation);
txSat1 = transmitter(gimbaltxSat,"Name",'Satellite Transmitter',"Frequency",frequency1, ...
"power",power1(SatNum),"BitRate",bitRate1(SatNum),"SystemLoss",systemLoss1,"MountingLocation",TxMountingLocation);
gaussianAntenna(rxSat1, ...
"DishDiameter",0.5); % meters
gaussianAntenna(txSat1, ...
"DishDiameter",0.5); % meters
display(SatNum)
end
the array contains 1,000 satellite objects and the aim is to add two gimbals to each satellite object, one for a transmitter and the other for a receiver, and afterwards to add the recveiver object and transmitter object to their appropriate gimbals.
- I have a quad intel i7 processor.
- the loop at the snippet runs until the 15th iteration as part of my trial and error with the commands, but it needs to run on the entire satellite array.
it takes a very long time to do this with a regular for loop.
will appreciate any suggestions,
thank you
Antworten (1)
Abhishek
am 14 Apr. 2023
Hello Etai,
I understand your objective to expedite certain operations on satellitescenario objects. However, it appears that sat objects are not being updated in the parfor loop.
Note that the sat variable is not shared between the different workers in parallel pool and is distinct for each worker. Therefore, any changes made to sat in one worker are not reflected in the other workers. As a result, the changes made to the variable in the parfor loop are not visible outside the loop.
To mitigate this issue, it is recommended to use a temporary variable. For instance, you can declare mySatArr as an empty cell array and use this subset for all subsequent operations. Please refer to the code snippet below:
startTime = datetime(2021,12,10,18,27,57); % 10 December 2021, 6:27:57 PM UTC
stopTime = startTime + hours(3); % 10 December 2021, 9:27:57 PM UTC
sampleTime = 60; % Seconds
sc = satelliteScenario(startTime,stopTime,sampleTime,"AutoSimulate",false);
sat = satellite(sc,"largeConstellation.tle");
numSatellites = numel(sat);
gainToNoiseTemperatureRatio1 = 5; % dB/K
systemLoss1 = 3;
TxMountingLocation = [0;0;1];
RxMountingLocation = [0;0;1];
frequency1 = 27e9; % Hz
%% power between 19 and 26 dBW
power1 = 19+(26-19)*rand(numSatellites,1); % dBW
%% bitRate between 16 and 27 Mbps
bitRate1 = 16 + (27-16)*rand(numSatellites,1); % Mbps
mySatArr = cell(1,1000);
parfor SatNum = 1:15
mySatArr{SatNum} = sat(SatNum);
gimbalrxSat = gimbal(mySatArr{SatNum},"MountingLocation",[0;-1;2]);
gimbaltxSat = gimbal(mySatArr{SatNum},"MountingLocation",[0;1;2]);
rxSat1 = receiver(gimbalrxSat,"Name",'Satellite Receiver',"GainToNoiseTemperatureRatio" ...
,gainToNoiseTemperatureRatio1,"SystemLoss",systemLoss1,"MountingLocation",RxMountingLocation);
txSat1 = transmitter(gimbaltxSat,"Name",'Satellite Transmitter',"Frequency",frequency1, ...
"power",power1(SatNum),"BitRate",bitRate1(SatNum),"SystemLoss",systemLoss1,"MountingLocation",TxMountingLocation);
gaussianAntenna(rxSat1, "DishDiameter",0.5); % meters
gaussianAntenna(txSat1, "DishDiameter",0.5); % meters
end
%First gimbal of 6th satellite
disp(mySatArr{6}.Gimbals(1))
For more information, you can refer to the following documentation pages:
1 Kommentar
Siehe auch
Kategorien
Mehr zu Scenario Generation and Visualization finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!