Category: Matlab
Category Archives: Matlab
Trouble with jsondecode() and jsonencode()
I have a JSON file. I am trying to test the MATLAB functions before using them. So I loaded it
str1 = fileread(‘json_filename1.json’);
mydata1 = jsondecode(str1)
str2 = jsonencode(mydata1)
fid = fopen(‘json_filename2.json’,’wt’)
fprintf(fid,str2)
fclose(fid)
Then I go to the online JSON file editor: https://jsoneditoronline.org/#left=local.jagoxe to load both files. I am able to load ‘json_filename1.json’ but I can’t load ‘json_filename2.json’ correctly. I got the following error message:
Failed to switch to "tree" mode because of Invalid JSON:
Parse error on line 1:
…,"errorDescription":"CreateACPath Execut
———————–^
Expecting ‘STRING’, ‘NUMBER’, ‘NULL’, ‘TRUE’, ‘FALSE’, ‘{‘, ‘[‘, got ‘undefined’
It looks like either jsondecode() or jsonencode() has something wrong.
Also, when I used strcmp(str1,str2), I saw a lot of difference between them.I have a JSON file. I am trying to test the MATLAB functions before using them. So I loaded it
str1 = fileread(‘json_filename1.json’);
mydata1 = jsondecode(str1)
str2 = jsonencode(mydata1)
fid = fopen(‘json_filename2.json’,’wt’)
fprintf(fid,str2)
fclose(fid)
Then I go to the online JSON file editor: https://jsoneditoronline.org/#left=local.jagoxe to load both files. I am able to load ‘json_filename1.json’ but I can’t load ‘json_filename2.json’ correctly. I got the following error message:
Failed to switch to "tree" mode because of Invalid JSON:
Parse error on line 1:
…,"errorDescription":"CreateACPath Execut
———————–^
Expecting ‘STRING’, ‘NUMBER’, ‘NULL’, ‘TRUE’, ‘FALSE’, ‘{‘, ‘[‘, got ‘undefined’
It looks like either jsondecode() or jsonencode() has something wrong.
Also, when I used strcmp(str1,str2), I saw a lot of difference between them. I have a JSON file. I am trying to test the MATLAB functions before using them. So I loaded it
str1 = fileread(‘json_filename1.json’);
mydata1 = jsondecode(str1)
str2 = jsonencode(mydata1)
fid = fopen(‘json_filename2.json’,’wt’)
fprintf(fid,str2)
fclose(fid)
Then I go to the online JSON file editor: https://jsoneditoronline.org/#left=local.jagoxe to load both files. I am able to load ‘json_filename1.json’ but I can’t load ‘json_filename2.json’ correctly. I got the following error message:
Failed to switch to "tree" mode because of Invalid JSON:
Parse error on line 1:
…,"errorDescription":"CreateACPath Execut
———————–^
Expecting ‘STRING’, ‘NUMBER’, ‘NULL’, ‘TRUE’, ‘FALSE’, ‘{‘, ‘[‘, got ‘undefined’
It looks like either jsondecode() or jsonencode() has something wrong.
Also, when I used strcmp(str1,str2), I saw a lot of difference between them. json MATLAB Answers — New Questions
Generate sphere whose center is not at origin
How do I generate a sphere with center at [x = 4.26, y = 1.76, z = 1.62] with a radius of 0.25 units? The sphere should have 101 points. The output should look like following figure. In the figure, the blue markers are the first 51 points of the 101 points and the red markers are the remaining 50 points. Attached also find, .fig format of the required output. Below this figure, is my code. However, I am unable to reproduce the required figure. Can anyone please help?
I = imread(‘Sphere.png’);
imshow(I);
%Center of sphere
recPosition = [4.26 1.76 1.62];
rng(0,’twister’);
radius = 0.25;
%Number of points
nPoints = 100;
%Create array
test_xyz = zeros(101,3);
test_xyz(1,1) = recPosition(1);
test_xyz(1,2) = recPosition(2);
test_xyz(1,3) = recPosition(3);
radius = zeros(nPoints,1)+radius ;
azimuth = rand(size(radius)) * 2*pi;
elevation = (rand(size(radius)) .* pi)-pi/2;
[x,y,z] = sph2cart(azimuth,elevation,radius);
test_xyz(2:end,1) = test_xyz(1,1)+x;
test_xyz(2:end,2) = test_xyz(1,2)+y;
test_xyz(2:end,3) = test_xyz(1,3)+z;
figure
scatter3(test_xyz(:,1),test_xyz(:,2),test_xyz(:,3));How do I generate a sphere with center at [x = 4.26, y = 1.76, z = 1.62] with a radius of 0.25 units? The sphere should have 101 points. The output should look like following figure. In the figure, the blue markers are the first 51 points of the 101 points and the red markers are the remaining 50 points. Attached also find, .fig format of the required output. Below this figure, is my code. However, I am unable to reproduce the required figure. Can anyone please help?
I = imread(‘Sphere.png’);
imshow(I);
%Center of sphere
recPosition = [4.26 1.76 1.62];
rng(0,’twister’);
radius = 0.25;
%Number of points
nPoints = 100;
%Create array
test_xyz = zeros(101,3);
test_xyz(1,1) = recPosition(1);
test_xyz(1,2) = recPosition(2);
test_xyz(1,3) = recPosition(3);
radius = zeros(nPoints,1)+radius ;
azimuth = rand(size(radius)) * 2*pi;
elevation = (rand(size(radius)) .* pi)-pi/2;
[x,y,z] = sph2cart(azimuth,elevation,radius);
test_xyz(2:end,1) = test_xyz(1,1)+x;
test_xyz(2:end,2) = test_xyz(1,2)+y;
test_xyz(2:end,3) = test_xyz(1,3)+z;
figure
scatter3(test_xyz(:,1),test_xyz(:,2),test_xyz(:,3)); How do I generate a sphere with center at [x = 4.26, y = 1.76, z = 1.62] with a radius of 0.25 units? The sphere should have 101 points. The output should look like following figure. In the figure, the blue markers are the first 51 points of the 101 points and the red markers are the remaining 50 points. Attached also find, .fig format of the required output. Below this figure, is my code. However, I am unable to reproduce the required figure. Can anyone please help?
I = imread(‘Sphere.png’);
imshow(I);
%Center of sphere
recPosition = [4.26 1.76 1.62];
rng(0,’twister’);
radius = 0.25;
%Number of points
nPoints = 100;
%Create array
test_xyz = zeros(101,3);
test_xyz(1,1) = recPosition(1);
test_xyz(1,2) = recPosition(2);
test_xyz(1,3) = recPosition(3);
radius = zeros(nPoints,1)+radius ;
azimuth = rand(size(radius)) * 2*pi;
elevation = (rand(size(radius)) .* pi)-pi/2;
[x,y,z] = sph2cart(azimuth,elevation,radius);
test_xyz(2:end,1) = test_xyz(1,1)+x;
test_xyz(2:end,2) = test_xyz(1,2)+y;
test_xyz(2:end,3) = test_xyz(1,3)+z;
figure
scatter3(test_xyz(:,1),test_xyz(:,2),test_xyz(:,3)); sphere, sph2cart, radius MATLAB Answers — New Questions
Using Observation Weights / set WeightsVar
In "Credit Scorecard Modeling Using Observation Weights" there is an example of using the weights, but it is not clear how to link column ‘CustAge’ with column ‘Weight’?
If I set creditscorecard(data,’GoodLabel’,0,’IDVar’,’CustID’,’ResponseVar’,’status’,’PredictorVars’,{‘CustAge’,’CustIncome’},’WeightsVar’,’Weight’,’BinMissingData’,true) how can I know it is linked to variable ‘CustAge’?
What if I have weights for more variables (‘CustAge’, ‘CustIncome’)? How will I link CustAge to its own Weight and CustIncome to its own Weight?In "Credit Scorecard Modeling Using Observation Weights" there is an example of using the weights, but it is not clear how to link column ‘CustAge’ with column ‘Weight’?
If I set creditscorecard(data,’GoodLabel’,0,’IDVar’,’CustID’,’ResponseVar’,’status’,’PredictorVars’,{‘CustAge’,’CustIncome’},’WeightsVar’,’Weight’,’BinMissingData’,true) how can I know it is linked to variable ‘CustAge’?
What if I have weights for more variables (‘CustAge’, ‘CustIncome’)? How will I link CustAge to its own Weight and CustIncome to its own Weight? In "Credit Scorecard Modeling Using Observation Weights" there is an example of using the weights, but it is not clear how to link column ‘CustAge’ with column ‘Weight’?
If I set creditscorecard(data,’GoodLabel’,0,’IDVar’,’CustID’,’ResponseVar’,’status’,’PredictorVars’,{‘CustAge’,’CustIncome’},’WeightsVar’,’Weight’,’BinMissingData’,true) how can I know it is linked to variable ‘CustAge’?
What if I have weights for more variables (‘CustAge’, ‘CustIncome’)? How will I link CustAge to its own Weight and CustIncome to its own Weight? scorecard MATLAB Answers — New Questions
For loop with moving window
Hi
I want to create a for-loop that calculates the weights of portfolios using a moving window for the period I am investigating. The moving window should move one day at a time and there are 1000 days in the window.
For example, compute the optimal weights on day1001 based on observations for period 1-1000days. Then you move on to day 1002, and re-calculate the weights, based on observations for period 2-1001days, etc.
I have a matrix of returns (Rets) that is 3740×6. The first column has the dates and the rest of the columns have daily returns for five different asset classes.
Thanks!Hi
I want to create a for-loop that calculates the weights of portfolios using a moving window for the period I am investigating. The moving window should move one day at a time and there are 1000 days in the window.
For example, compute the optimal weights on day1001 based on observations for period 1-1000days. Then you move on to day 1002, and re-calculate the weights, based on observations for period 2-1001days, etc.
I have a matrix of returns (Rets) that is 3740×6. The first column has the dates and the rest of the columns have daily returns for five different asset classes.
Thanks! Hi
I want to create a for-loop that calculates the weights of portfolios using a moving window for the period I am investigating. The moving window should move one day at a time and there are 1000 days in the window.
For example, compute the optimal weights on day1001 based on observations for period 1-1000days. Then you move on to day 1002, and re-calculate the weights, based on observations for period 2-1001days, etc.
I have a matrix of returns (Rets) that is 3740×6. The first column has the dates and the rest of the columns have daily returns for five different asset classes.
Thanks! for loop, moving window, portfolio optimization, rebalancing MATLAB Answers — New Questions
How to adjust font size in Matlab editor
I want to adjust the font size in the Matlab editor (R2024a running on Mac, M3 chip, OS Sonoma 14.5).
Matlab>Settings>Fonts gives me the option of specifying a font for "Command Window, Command History, Editor". I can change the font (I choose a larger font) and it is used by Command window and Command History, but not by the Editor. The default font for the Editor is too small to read comfortably.
Thanks.I want to adjust the font size in the Matlab editor (R2024a running on Mac, M3 chip, OS Sonoma 14.5).
Matlab>Settings>Fonts gives me the option of specifying a font for "Command Window, Command History, Editor". I can change the font (I choose a larger font) and it is used by Command window and Command History, but not by the Editor. The default font for the Editor is too small to read comfortably.
Thanks. I want to adjust the font size in the Matlab editor (R2024a running on Mac, M3 chip, OS Sonoma 14.5).
Matlab>Settings>Fonts gives me the option of specifying a font for "Command Window, Command History, Editor". I can change the font (I choose a larger font) and it is used by Command window and Command History, but not by the Editor. The default font for the Editor is too small to read comfortably.
Thanks. matlab editor, font size MATLAB Answers — New Questions
how can I add new property to a platform, Unrecognized property ‘Height’ for class ‘matlabshared.satellitescenario.Platform’.
%Load the Aircraft Trajectory
aircraft = load("aircraftTT.mat");
aircraft1 = load("aircraftTT1.mat");
aircraft2 = load("aircraftTT2.mat");
aircraft3 = load("aircraftTT3.mat");
aircraft4 = load("aircraftTT4.mat");
geoplot(aircraft.aircraftTT.AircraftLLA(:,1), aircraft.aircraftTT.AircraftLLA(:,2), "b–",…
aircraft1.aircraftTT1.AircraftLLA1(:,1), aircraft1.aircraftTT1.AircraftLLA1(:,2), "r–",…
aircraft2.aircraftTT2.AircraftLLA2(:,1), aircraft2.aircraftTT2.AircraftLLA2(:,2), "k–",…
aircraft3.aircraftTT3.AircraftLLA3(:,1), aircraft3.aircraftTT3.AircraftLLA3(:,2), "g–",…
aircraft4.aircraftTT4.AircraftLLA4(:,1), aircraft4.aircraftTT4.AircraftLLA4(:,2), "c–"…
)
title("Aircrafts Trajectories")
%legend(‘show’);
geobasemap streets
geolimits([38.0887 38.1099],[140.6330 140.6660])
%Load the Vehicles path
gx = geoaxes;
geolimits(gx,[38.0887,38.1099],[140.6330,140.6660]);
title("Vehicles Path")
geobasemap(gx,"streets");
useManualInput = true;
if useManualInput
waypoints = zeros(15,3); %#ok<*UNRCH>
numWaypoints = size(waypoints,1);
[lat,lon] = ginput(numWaypoints);
waypoints = [lat lon ones(numWaypoints,1)];
else
waypoints = […
42.265387594440746, -71.566584651695194, 1; …
42.263702708358274, -71.569614091115028, 1; …
42.262575723421115, -71.573098554161504, 1; …
42.260479485544565, -71.575579488911472, 1; …
42.258318030927740, -71.578013745650068, 1; …
42.256140084405871, -71.580417734892066, 1; …
42.253864954613888, -71.582655636609843, 1; …
42.251556291741792, -71.584827877421873, 1; …
42.249201618438420, -71.586910025508118, 1; …
42.246834381495290, -71.588965321234468, 1; …
42.244433745609328, -71.590949233154006, 1; …
42.242264173597064, -71.593357390593781, 1; …
42.240253137371795, -71.596002172990822, 1; …
42.238444180204169, -71.598914079082988, 1; …
42.236661606027504, -71.601851940116248, 1; …
42.235163293921218, -71.605069451220544, 1; …
42.233664981814933, -71.608286962324840, 1; …
42.232221634012099, -71.611549664950445, 1; …
42.230785995268782, -71.614818705946718, 1; …
42.229491349524331, -71.618178093198480, 1; …
42.228523450114722, -71.621746854731867, 1; …
42.227591252458026, -71.625329339092573, 1; …
42.227021657836168, -71.629051198649620, 1; …
42.226488781649429, -71.632774933477108, 1; …
42.226848543969822, -71.636544256810438, 1; …
42.227208306290223, -71.640313580143768, 1; …
42.227475917842995, -71.644096605079170, 1; …
42.227730436282329, -71.647881576787640, 1; …
42.227949419806208, -71.651670397035346, 1; …
42.228142838835581, -71.655461985995458, 1; …
42.228336257864946, -71.659253574955557, 1];
lat = waypoints(:,1);
lon = waypoints(:,2);
end
geoplot(gx,lat,lon,’r-‘)
title("Vehicles Path")
% Find the distance in statute miles between each waypoint
distInDeg = distance(waypoints(1:end-1,1:2),waypoints(2:end,1:2)); % deg
distInSM = deg2sm(distInDeg); % statute miles
carSpeed = 70 / 3600; % miles per second
timeOfArrival = [0; cumsum(distInSM) / carSpeed]; % seconds
carPath = geoTrajectory(waypoints,timeOfArrival);
%Define Mission Start Date and Duration"Creating the scenario"
mission.StartDate = datetime(2024,7,24,02,42,30,TimeZone="UTC");
mission.StopTime = mission.StartDate + hours(2) + minutes(2);
mission.Duration = hours(2); %should remove, I’ve already defined above
sampleTime = 10;
mission.scenario = satelliteScenario(mission.StartDate, mission.StopTime,sampleTime);
mission.viewer = satelliteScenarioViewer(mission.scenario);
%Add Vehicles to a Satellite Scenario
car = platform(mission.scenario,carPath, Name = "Car");
%Add Aircrafts to a Satellite Scenario
aircraft = platform(mission.scenario,aircraft.aircraftTT,Name="Aircraft1", Visual3DModel="NarrowBodyAirliner.glb")
%camtarget(mission.viewer,aircraft);
aircraft1 = platform(mission.scenario,aircraft1.aircraftTT1,Name="Aircraft2", Visual3DModel="NarrowBodyAirliner.glb")
%camtarget(mission.viewer,aircraft1);
aircraft2 = platform(mission.scenario,aircraft2.aircraftTT2,Name="Aircraft3", Visual3DModel="NarrowBodyAirliner.glb")
%camtarget(mission.viewer,aircraft2);
aircraft3 = platform(mission.scenario,aircraft3.aircraftTT3,Name="Aircraft4", Visual3DModel="NarrowBodyAirliner.glb")
%camtarget(mission.viewer,aircraft3);
aircraft4 = platform(mission.scenario,aircraft4.aircraftTT4,Name="Aircraft5", Visual3DModel="NarrowBodyAirliner.glb")
%camtarget(mission.viewer,aircraft4);
%Add a Starlink Constellation to the Satellite Scenario-TLE files
sat = satellite(mission.scenario,"2024-001B.tle", Visual3DModel="SmallSat.glb");
show(sat)
groundTrack(sat,"LeadTime",1200);
%Aircraft-to-Vehicles Access Analysis
Preq = -35.5; % Required signal power in dBm
Ptx = 17.5; % Transmitted power in dBm
% Configure the ground station, satellites, and link characteristics
% Set the ground station characteristics with parabolic telescope
%gs = struct;
car.Height = 1; % Height above the mean sea level in km
car.OpticsEfficiency = 0.8; % Optical antenna efficiency
car.ApertureDiameter = 1; % Antenna aperture diameter in m
car.PointingError = 1e-6; % Pointing error in rad
% Set the satellite A characteristics with parabolic telescope
aircraft = struct;
aircraft.Height = 550; % Height above the mean sea level in km
aircraft.OpticsEfficiency = 0.8; % Optical antenna efficiency
aircraft.ApertureDiameter = 0.07; % Antenna aperture diameter in m
aircraft.PointingError = 1e-6; % Pointing error in rad
% Set the link characteristics
link = struct;
link.Wavelength = 1550e-9; % m
link.TroposphereHeight = 20; % km (Typically ranges from 6-20 km)
link.ElevationAngle = 50; % degrees
%link.Type = "downlink"; % "downlink"|"inter-satellite"|"uplink"
% When the Type field is set to "uplink" or "downlink", you must specify
% the CloudType field, as defined in [5] table 1
link.CloudType = "Thin cirrus";
tx = transmitter(car);
rx = receiver(aircraft,MountingAngles=[0; 180; 0]);
% Calculate transmitter and receiver gain
txGain = (pi*tx.ApertureDiameter/link.Wavelength)^2;
Gtx = 10*log10(txGain); % in dB
rxGain = (pi*rx.ApertureDiameter/link.Wavelength)^2;
Grx = 10*log10(rxGain); % in dB
% Calculate transmitter and receiver pointing loss in dB
txPointingLoss = 4.3429*(txGain*(tx.PointingError)^2);
rxPointingLoss = 4.3429*(rxGain*(rx.PointingError)^2);
absorptionLoss = 0.01; % Absorption loss in dB
% Calculate the distance of the optical beam that propagates through
% the troposphere layer of the atmosphere in km
dT = (link.TroposphereHeight – gs.Height).*cscd(link.ElevationAngle);
% Calculate the slant distance for uplink and downlink between
% satellite A and the ground station for circular orbit in m
dGS = slantRangeCircularOrbit(link.ElevationAngle,satA.Height*1e3,gs.Height*1e3);
% Calculate free-space path loss between the ground station and
% satellite in dB
pathLoss = fspl(dGS,link.Wavelength);
% Calculate loss due to geometrical scattering
% cnc – cloud number concentration in cm-3
% lwc – Liquid water content in g/m-3
[cnc,lwc] = getCloudParameters(link.CloudType);
visibility = 1.002/((lwc*cnc)^0.6473); % Calculate visibility in km
% Get particle size related coefficient
if visibility<=0.5
delta = 0;
elseif visibility>0.5 && visibility<=1
delta = visibility – 0.5;
elseif visibility>1 && visibility<=6
delta = 0.16*visibility + 0.34;
elseif visibility>=6 && visibility<=50
delta = 1.3;
else % visibility>50
delta = 1.6;
end
geoCoeff = (3.91/visibility)* …
((link.Wavelength*1e9/550)^-delta); % Extinction coefficient
geoScaLoss = 4.3429*geoCoeff*dT; % Geometrical scattering loss in dB
% Calculate loss due to Mie scattering
lambda_mu = link.Wavelength*1e6; % Wavelength in microns
% Calculate empirical coefficients
a = (0.000487*(lambda_mu^3)) – (0.002237*(lambda_mu^2)) + …
(0.003864*lambda_mu) – 0.004442;
b = (-0.00573*(lambda_mu^3)) + (0.02639*(lambda_mu^2)) – …
(0.04552*lambda_mu) + 0.05164;
c = (0.02565*(lambda_mu^3)) – (0.1191*(lambda_mu^2)) + …
(0.20385*lambda_mu) – 0.216;
d = (-0.0638*(lambda_mu^3)) + (0.3034*(lambda_mu^2)) – …
(0.5083*lambda_mu) + 0.425;
mieER = a*(gs.Height^3) + b*(gs.Height^2) + …
c*(gs.Height) + d; % Extinction ratio
mieScaLoss = (4.3429*mieER)./sind(link.ElevationAngle); % Mie scattering loss in dB
% Calculate link margin for uplink or downlink in dB
linkMargin = Ptx + 10*log10(tx.OpticsEfficiency) + …
10*log10(rx.OpticsEfficiency) + Gtx + Grx – …
txPointingLoss – rxPointingLoss – pathLoss – …
absorptionLoss – geoScaLoss – mieScaLoss – Preq;
disp("Link margin for "+num2str(link.Type)+" is "+num2str(linkMargin)+" dB")%Load the Aircraft Trajectory
aircraft = load("aircraftTT.mat");
aircraft1 = load("aircraftTT1.mat");
aircraft2 = load("aircraftTT2.mat");
aircraft3 = load("aircraftTT3.mat");
aircraft4 = load("aircraftTT4.mat");
geoplot(aircraft.aircraftTT.AircraftLLA(:,1), aircraft.aircraftTT.AircraftLLA(:,2), "b–",…
aircraft1.aircraftTT1.AircraftLLA1(:,1), aircraft1.aircraftTT1.AircraftLLA1(:,2), "r–",…
aircraft2.aircraftTT2.AircraftLLA2(:,1), aircraft2.aircraftTT2.AircraftLLA2(:,2), "k–",…
aircraft3.aircraftTT3.AircraftLLA3(:,1), aircraft3.aircraftTT3.AircraftLLA3(:,2), "g–",…
aircraft4.aircraftTT4.AircraftLLA4(:,1), aircraft4.aircraftTT4.AircraftLLA4(:,2), "c–"…
)
title("Aircrafts Trajectories")
%legend(‘show’);
geobasemap streets
geolimits([38.0887 38.1099],[140.6330 140.6660])
%Load the Vehicles path
gx = geoaxes;
geolimits(gx,[38.0887,38.1099],[140.6330,140.6660]);
title("Vehicles Path")
geobasemap(gx,"streets");
useManualInput = true;
if useManualInput
waypoints = zeros(15,3); %#ok<*UNRCH>
numWaypoints = size(waypoints,1);
[lat,lon] = ginput(numWaypoints);
waypoints = [lat lon ones(numWaypoints,1)];
else
waypoints = […
42.265387594440746, -71.566584651695194, 1; …
42.263702708358274, -71.569614091115028, 1; …
42.262575723421115, -71.573098554161504, 1; …
42.260479485544565, -71.575579488911472, 1; …
42.258318030927740, -71.578013745650068, 1; …
42.256140084405871, -71.580417734892066, 1; …
42.253864954613888, -71.582655636609843, 1; …
42.251556291741792, -71.584827877421873, 1; …
42.249201618438420, -71.586910025508118, 1; …
42.246834381495290, -71.588965321234468, 1; …
42.244433745609328, -71.590949233154006, 1; …
42.242264173597064, -71.593357390593781, 1; …
42.240253137371795, -71.596002172990822, 1; …
42.238444180204169, -71.598914079082988, 1; …
42.236661606027504, -71.601851940116248, 1; …
42.235163293921218, -71.605069451220544, 1; …
42.233664981814933, -71.608286962324840, 1; …
42.232221634012099, -71.611549664950445, 1; …
42.230785995268782, -71.614818705946718, 1; …
42.229491349524331, -71.618178093198480, 1; …
42.228523450114722, -71.621746854731867, 1; …
42.227591252458026, -71.625329339092573, 1; …
42.227021657836168, -71.629051198649620, 1; …
42.226488781649429, -71.632774933477108, 1; …
42.226848543969822, -71.636544256810438, 1; …
42.227208306290223, -71.640313580143768, 1; …
42.227475917842995, -71.644096605079170, 1; …
42.227730436282329, -71.647881576787640, 1; …
42.227949419806208, -71.651670397035346, 1; …
42.228142838835581, -71.655461985995458, 1; …
42.228336257864946, -71.659253574955557, 1];
lat = waypoints(:,1);
lon = waypoints(:,2);
end
geoplot(gx,lat,lon,’r-‘)
title("Vehicles Path")
% Find the distance in statute miles between each waypoint
distInDeg = distance(waypoints(1:end-1,1:2),waypoints(2:end,1:2)); % deg
distInSM = deg2sm(distInDeg); % statute miles
carSpeed = 70 / 3600; % miles per second
timeOfArrival = [0; cumsum(distInSM) / carSpeed]; % seconds
carPath = geoTrajectory(waypoints,timeOfArrival);
%Define Mission Start Date and Duration"Creating the scenario"
mission.StartDate = datetime(2024,7,24,02,42,30,TimeZone="UTC");
mission.StopTime = mission.StartDate + hours(2) + minutes(2);
mission.Duration = hours(2); %should remove, I’ve already defined above
sampleTime = 10;
mission.scenario = satelliteScenario(mission.StartDate, mission.StopTime,sampleTime);
mission.viewer = satelliteScenarioViewer(mission.scenario);
%Add Vehicles to a Satellite Scenario
car = platform(mission.scenario,carPath, Name = "Car");
%Add Aircrafts to a Satellite Scenario
aircraft = platform(mission.scenario,aircraft.aircraftTT,Name="Aircraft1", Visual3DModel="NarrowBodyAirliner.glb")
%camtarget(mission.viewer,aircraft);
aircraft1 = platform(mission.scenario,aircraft1.aircraftTT1,Name="Aircraft2", Visual3DModel="NarrowBodyAirliner.glb")
%camtarget(mission.viewer,aircraft1);
aircraft2 = platform(mission.scenario,aircraft2.aircraftTT2,Name="Aircraft3", Visual3DModel="NarrowBodyAirliner.glb")
%camtarget(mission.viewer,aircraft2);
aircraft3 = platform(mission.scenario,aircraft3.aircraftTT3,Name="Aircraft4", Visual3DModel="NarrowBodyAirliner.glb")
%camtarget(mission.viewer,aircraft3);
aircraft4 = platform(mission.scenario,aircraft4.aircraftTT4,Name="Aircraft5", Visual3DModel="NarrowBodyAirliner.glb")
%camtarget(mission.viewer,aircraft4);
%Add a Starlink Constellation to the Satellite Scenario-TLE files
sat = satellite(mission.scenario,"2024-001B.tle", Visual3DModel="SmallSat.glb");
show(sat)
groundTrack(sat,"LeadTime",1200);
%Aircraft-to-Vehicles Access Analysis
Preq = -35.5; % Required signal power in dBm
Ptx = 17.5; % Transmitted power in dBm
% Configure the ground station, satellites, and link characteristics
% Set the ground station characteristics with parabolic telescope
%gs = struct;
car.Height = 1; % Height above the mean sea level in km
car.OpticsEfficiency = 0.8; % Optical antenna efficiency
car.ApertureDiameter = 1; % Antenna aperture diameter in m
car.PointingError = 1e-6; % Pointing error in rad
% Set the satellite A characteristics with parabolic telescope
aircraft = struct;
aircraft.Height = 550; % Height above the mean sea level in km
aircraft.OpticsEfficiency = 0.8; % Optical antenna efficiency
aircraft.ApertureDiameter = 0.07; % Antenna aperture diameter in m
aircraft.PointingError = 1e-6; % Pointing error in rad
% Set the link characteristics
link = struct;
link.Wavelength = 1550e-9; % m
link.TroposphereHeight = 20; % km (Typically ranges from 6-20 km)
link.ElevationAngle = 50; % degrees
%link.Type = "downlink"; % "downlink"|"inter-satellite"|"uplink"
% When the Type field is set to "uplink" or "downlink", you must specify
% the CloudType field, as defined in [5] table 1
link.CloudType = "Thin cirrus";
tx = transmitter(car);
rx = receiver(aircraft,MountingAngles=[0; 180; 0]);
% Calculate transmitter and receiver gain
txGain = (pi*tx.ApertureDiameter/link.Wavelength)^2;
Gtx = 10*log10(txGain); % in dB
rxGain = (pi*rx.ApertureDiameter/link.Wavelength)^2;
Grx = 10*log10(rxGain); % in dB
% Calculate transmitter and receiver pointing loss in dB
txPointingLoss = 4.3429*(txGain*(tx.PointingError)^2);
rxPointingLoss = 4.3429*(rxGain*(rx.PointingError)^2);
absorptionLoss = 0.01; % Absorption loss in dB
% Calculate the distance of the optical beam that propagates through
% the troposphere layer of the atmosphere in km
dT = (link.TroposphereHeight – gs.Height).*cscd(link.ElevationAngle);
% Calculate the slant distance for uplink and downlink between
% satellite A and the ground station for circular orbit in m
dGS = slantRangeCircularOrbit(link.ElevationAngle,satA.Height*1e3,gs.Height*1e3);
% Calculate free-space path loss between the ground station and
% satellite in dB
pathLoss = fspl(dGS,link.Wavelength);
% Calculate loss due to geometrical scattering
% cnc – cloud number concentration in cm-3
% lwc – Liquid water content in g/m-3
[cnc,lwc] = getCloudParameters(link.CloudType);
visibility = 1.002/((lwc*cnc)^0.6473); % Calculate visibility in km
% Get particle size related coefficient
if visibility<=0.5
delta = 0;
elseif visibility>0.5 && visibility<=1
delta = visibility – 0.5;
elseif visibility>1 && visibility<=6
delta = 0.16*visibility + 0.34;
elseif visibility>=6 && visibility<=50
delta = 1.3;
else % visibility>50
delta = 1.6;
end
geoCoeff = (3.91/visibility)* …
((link.Wavelength*1e9/550)^-delta); % Extinction coefficient
geoScaLoss = 4.3429*geoCoeff*dT; % Geometrical scattering loss in dB
% Calculate loss due to Mie scattering
lambda_mu = link.Wavelength*1e6; % Wavelength in microns
% Calculate empirical coefficients
a = (0.000487*(lambda_mu^3)) – (0.002237*(lambda_mu^2)) + …
(0.003864*lambda_mu) – 0.004442;
b = (-0.00573*(lambda_mu^3)) + (0.02639*(lambda_mu^2)) – …
(0.04552*lambda_mu) + 0.05164;
c = (0.02565*(lambda_mu^3)) – (0.1191*(lambda_mu^2)) + …
(0.20385*lambda_mu) – 0.216;
d = (-0.0638*(lambda_mu^3)) + (0.3034*(lambda_mu^2)) – …
(0.5083*lambda_mu) + 0.425;
mieER = a*(gs.Height^3) + b*(gs.Height^2) + …
c*(gs.Height) + d; % Extinction ratio
mieScaLoss = (4.3429*mieER)./sind(link.ElevationAngle); % Mie scattering loss in dB
% Calculate link margin for uplink or downlink in dB
linkMargin = Ptx + 10*log10(tx.OpticsEfficiency) + …
10*log10(rx.OpticsEfficiency) + Gtx + Grx – …
txPointingLoss – rxPointingLoss – pathLoss – …
absorptionLoss – geoScaLoss – mieScaLoss – Preq;
disp("Link margin for "+num2str(link.Type)+" is "+num2str(linkMargin)+" dB") %Load the Aircraft Trajectory
aircraft = load("aircraftTT.mat");
aircraft1 = load("aircraftTT1.mat");
aircraft2 = load("aircraftTT2.mat");
aircraft3 = load("aircraftTT3.mat");
aircraft4 = load("aircraftTT4.mat");
geoplot(aircraft.aircraftTT.AircraftLLA(:,1), aircraft.aircraftTT.AircraftLLA(:,2), "b–",…
aircraft1.aircraftTT1.AircraftLLA1(:,1), aircraft1.aircraftTT1.AircraftLLA1(:,2), "r–",…
aircraft2.aircraftTT2.AircraftLLA2(:,1), aircraft2.aircraftTT2.AircraftLLA2(:,2), "k–",…
aircraft3.aircraftTT3.AircraftLLA3(:,1), aircraft3.aircraftTT3.AircraftLLA3(:,2), "g–",…
aircraft4.aircraftTT4.AircraftLLA4(:,1), aircraft4.aircraftTT4.AircraftLLA4(:,2), "c–"…
)
title("Aircrafts Trajectories")
%legend(‘show’);
geobasemap streets
geolimits([38.0887 38.1099],[140.6330 140.6660])
%Load the Vehicles path
gx = geoaxes;
geolimits(gx,[38.0887,38.1099],[140.6330,140.6660]);
title("Vehicles Path")
geobasemap(gx,"streets");
useManualInput = true;
if useManualInput
waypoints = zeros(15,3); %#ok<*UNRCH>
numWaypoints = size(waypoints,1);
[lat,lon] = ginput(numWaypoints);
waypoints = [lat lon ones(numWaypoints,1)];
else
waypoints = […
42.265387594440746, -71.566584651695194, 1; …
42.263702708358274, -71.569614091115028, 1; …
42.262575723421115, -71.573098554161504, 1; …
42.260479485544565, -71.575579488911472, 1; …
42.258318030927740, -71.578013745650068, 1; …
42.256140084405871, -71.580417734892066, 1; …
42.253864954613888, -71.582655636609843, 1; …
42.251556291741792, -71.584827877421873, 1; …
42.249201618438420, -71.586910025508118, 1; …
42.246834381495290, -71.588965321234468, 1; …
42.244433745609328, -71.590949233154006, 1; …
42.242264173597064, -71.593357390593781, 1; …
42.240253137371795, -71.596002172990822, 1; …
42.238444180204169, -71.598914079082988, 1; …
42.236661606027504, -71.601851940116248, 1; …
42.235163293921218, -71.605069451220544, 1; …
42.233664981814933, -71.608286962324840, 1; …
42.232221634012099, -71.611549664950445, 1; …
42.230785995268782, -71.614818705946718, 1; …
42.229491349524331, -71.618178093198480, 1; …
42.228523450114722, -71.621746854731867, 1; …
42.227591252458026, -71.625329339092573, 1; …
42.227021657836168, -71.629051198649620, 1; …
42.226488781649429, -71.632774933477108, 1; …
42.226848543969822, -71.636544256810438, 1; …
42.227208306290223, -71.640313580143768, 1; …
42.227475917842995, -71.644096605079170, 1; …
42.227730436282329, -71.647881576787640, 1; …
42.227949419806208, -71.651670397035346, 1; …
42.228142838835581, -71.655461985995458, 1; …
42.228336257864946, -71.659253574955557, 1];
lat = waypoints(:,1);
lon = waypoints(:,2);
end
geoplot(gx,lat,lon,’r-‘)
title("Vehicles Path")
% Find the distance in statute miles between each waypoint
distInDeg = distance(waypoints(1:end-1,1:2),waypoints(2:end,1:2)); % deg
distInSM = deg2sm(distInDeg); % statute miles
carSpeed = 70 / 3600; % miles per second
timeOfArrival = [0; cumsum(distInSM) / carSpeed]; % seconds
carPath = geoTrajectory(waypoints,timeOfArrival);
%Define Mission Start Date and Duration"Creating the scenario"
mission.StartDate = datetime(2024,7,24,02,42,30,TimeZone="UTC");
mission.StopTime = mission.StartDate + hours(2) + minutes(2);
mission.Duration = hours(2); %should remove, I’ve already defined above
sampleTime = 10;
mission.scenario = satelliteScenario(mission.StartDate, mission.StopTime,sampleTime);
mission.viewer = satelliteScenarioViewer(mission.scenario);
%Add Vehicles to a Satellite Scenario
car = platform(mission.scenario,carPath, Name = "Car");
%Add Aircrafts to a Satellite Scenario
aircraft = platform(mission.scenario,aircraft.aircraftTT,Name="Aircraft1", Visual3DModel="NarrowBodyAirliner.glb")
%camtarget(mission.viewer,aircraft);
aircraft1 = platform(mission.scenario,aircraft1.aircraftTT1,Name="Aircraft2", Visual3DModel="NarrowBodyAirliner.glb")
%camtarget(mission.viewer,aircraft1);
aircraft2 = platform(mission.scenario,aircraft2.aircraftTT2,Name="Aircraft3", Visual3DModel="NarrowBodyAirliner.glb")
%camtarget(mission.viewer,aircraft2);
aircraft3 = platform(mission.scenario,aircraft3.aircraftTT3,Name="Aircraft4", Visual3DModel="NarrowBodyAirliner.glb")
%camtarget(mission.viewer,aircraft3);
aircraft4 = platform(mission.scenario,aircraft4.aircraftTT4,Name="Aircraft5", Visual3DModel="NarrowBodyAirliner.glb")
%camtarget(mission.viewer,aircraft4);
%Add a Starlink Constellation to the Satellite Scenario-TLE files
sat = satellite(mission.scenario,"2024-001B.tle", Visual3DModel="SmallSat.glb");
show(sat)
groundTrack(sat,"LeadTime",1200);
%Aircraft-to-Vehicles Access Analysis
Preq = -35.5; % Required signal power in dBm
Ptx = 17.5; % Transmitted power in dBm
% Configure the ground station, satellites, and link characteristics
% Set the ground station characteristics with parabolic telescope
%gs = struct;
car.Height = 1; % Height above the mean sea level in km
car.OpticsEfficiency = 0.8; % Optical antenna efficiency
car.ApertureDiameter = 1; % Antenna aperture diameter in m
car.PointingError = 1e-6; % Pointing error in rad
% Set the satellite A characteristics with parabolic telescope
aircraft = struct;
aircraft.Height = 550; % Height above the mean sea level in km
aircraft.OpticsEfficiency = 0.8; % Optical antenna efficiency
aircraft.ApertureDiameter = 0.07; % Antenna aperture diameter in m
aircraft.PointingError = 1e-6; % Pointing error in rad
% Set the link characteristics
link = struct;
link.Wavelength = 1550e-9; % m
link.TroposphereHeight = 20; % km (Typically ranges from 6-20 km)
link.ElevationAngle = 50; % degrees
%link.Type = "downlink"; % "downlink"|"inter-satellite"|"uplink"
% When the Type field is set to "uplink" or "downlink", you must specify
% the CloudType field, as defined in [5] table 1
link.CloudType = "Thin cirrus";
tx = transmitter(car);
rx = receiver(aircraft,MountingAngles=[0; 180; 0]);
% Calculate transmitter and receiver gain
txGain = (pi*tx.ApertureDiameter/link.Wavelength)^2;
Gtx = 10*log10(txGain); % in dB
rxGain = (pi*rx.ApertureDiameter/link.Wavelength)^2;
Grx = 10*log10(rxGain); % in dB
% Calculate transmitter and receiver pointing loss in dB
txPointingLoss = 4.3429*(txGain*(tx.PointingError)^2);
rxPointingLoss = 4.3429*(rxGain*(rx.PointingError)^2);
absorptionLoss = 0.01; % Absorption loss in dB
% Calculate the distance of the optical beam that propagates through
% the troposphere layer of the atmosphere in km
dT = (link.TroposphereHeight – gs.Height).*cscd(link.ElevationAngle);
% Calculate the slant distance for uplink and downlink between
% satellite A and the ground station for circular orbit in m
dGS = slantRangeCircularOrbit(link.ElevationAngle,satA.Height*1e3,gs.Height*1e3);
% Calculate free-space path loss between the ground station and
% satellite in dB
pathLoss = fspl(dGS,link.Wavelength);
% Calculate loss due to geometrical scattering
% cnc – cloud number concentration in cm-3
% lwc – Liquid water content in g/m-3
[cnc,lwc] = getCloudParameters(link.CloudType);
visibility = 1.002/((lwc*cnc)^0.6473); % Calculate visibility in km
% Get particle size related coefficient
if visibility<=0.5
delta = 0;
elseif visibility>0.5 && visibility<=1
delta = visibility – 0.5;
elseif visibility>1 && visibility<=6
delta = 0.16*visibility + 0.34;
elseif visibility>=6 && visibility<=50
delta = 1.3;
else % visibility>50
delta = 1.6;
end
geoCoeff = (3.91/visibility)* …
((link.Wavelength*1e9/550)^-delta); % Extinction coefficient
geoScaLoss = 4.3429*geoCoeff*dT; % Geometrical scattering loss in dB
% Calculate loss due to Mie scattering
lambda_mu = link.Wavelength*1e6; % Wavelength in microns
% Calculate empirical coefficients
a = (0.000487*(lambda_mu^3)) – (0.002237*(lambda_mu^2)) + …
(0.003864*lambda_mu) – 0.004442;
b = (-0.00573*(lambda_mu^3)) + (0.02639*(lambda_mu^2)) – …
(0.04552*lambda_mu) + 0.05164;
c = (0.02565*(lambda_mu^3)) – (0.1191*(lambda_mu^2)) + …
(0.20385*lambda_mu) – 0.216;
d = (-0.0638*(lambda_mu^3)) + (0.3034*(lambda_mu^2)) – …
(0.5083*lambda_mu) + 0.425;
mieER = a*(gs.Height^3) + b*(gs.Height^2) + …
c*(gs.Height) + d; % Extinction ratio
mieScaLoss = (4.3429*mieER)./sind(link.ElevationAngle); % Mie scattering loss in dB
% Calculate link margin for uplink or downlink in dB
linkMargin = Ptx + 10*log10(tx.OpticsEfficiency) + …
10*log10(rx.OpticsEfficiency) + Gtx + Grx – …
txPointingLoss – rxPointingLoss – pathLoss – …
absorptionLoss – geoScaLoss – mieScaLoss – Preq;
disp("Link margin for "+num2str(link.Type)+" is "+num2str(linkMargin)+" dB") satellite, car MATLAB Answers — New Questions
Why do I receive the error “Failed to open file” when I read an AVI file using AVIREAD command on MATLAB 7.8 (R2009a)?
I have an image processing program that I have written that has worked fine for the last 6-8 months, and suddenly last week it stopped working. I have tracked the problem down to AVI file handling. I can no longer open them. I have tried rebooting the machine and reinstalling MATLAB. But nothing seems to work. I have ensured that I have permissions to read and write on the file as well as the directory in which the file resides. Using the following commands, I get the following errors, it happens for any filename, whether the file has been used before or not:
>> clear all
>> clear mex
>> test = avifile(‘avitest.avi’)
ERROR: ??? Error using ==> avi
Failed to open file.
Error in ==> avifile.avifile at 173
aviobj.FileHandle = avi(‘open’,filename);
>> mov=aviread(‘Filename.avi’)
ERROR: ??? Error using ==> aviread at 76
Unable to open file.I have an image processing program that I have written that has worked fine for the last 6-8 months, and suddenly last week it stopped working. I have tracked the problem down to AVI file handling. I can no longer open them. I have tried rebooting the machine and reinstalling MATLAB. But nothing seems to work. I have ensured that I have permissions to read and write on the file as well as the directory in which the file resides. Using the following commands, I get the following errors, it happens for any filename, whether the file has been used before or not:
>> clear all
>> clear mex
>> test = avifile(‘avitest.avi’)
ERROR: ??? Error using ==> avi
Failed to open file.
Error in ==> avifile.avifile at 173
aviobj.FileHandle = avi(‘open’,filename);
>> mov=aviread(‘Filename.avi’)
ERROR: ??? Error using ==> aviread at 76
Unable to open file. I have an image processing program that I have written that has worked fine for the last 6-8 months, and suddenly last week it stopped working. I have tracked the problem down to AVI file handling. I can no longer open them. I have tried rebooting the machine and reinstalling MATLAB. But nothing seems to work. I have ensured that I have permissions to read and write on the file as well as the directory in which the file resides. Using the following commands, I get the following errors, it happens for any filename, whether the file has been used before or not:
>> clear all
>> clear mex
>> test = avifile(‘avitest.avi’)
ERROR: ??? Error using ==> avi
Failed to open file.
Error in ==> avifile.avifile at 173
aviobj.FileHandle = avi(‘open’,filename);
>> mov=aviread(‘Filename.avi’)
ERROR: ??? Error using ==> aviread at 76
Unable to open file. MATLAB Answers — New Questions
How do I set up MATLAB Web Server using Apache as an httpd server on Windows NT?
How do I set up MATLAB Web Server using Apache as an httpd server on Windows NT?How do I set up MATLAB Web Server using Apache as an httpd server on Windows NT? How do I set up MATLAB Web Server using Apache as an httpd server on Windows NT? apache, windows, nt, web, server MATLAB Answers — New Questions
When I log into MATLAB Grader, I am asked whether I am an instructor or student, with a message saying I do not yet have access. How do I gain access to MATLAB Grader?
When I log into MATLAB Grader, I am asked whether I am an instructor or student, with a message saying I do not yet have access. How do I gain access to MATLAB Grader?When I log into MATLAB Grader, I am asked whether I am an instructor or student, with a message saying I do not yet have access. How do I gain access to MATLAB Grader? When I log into MATLAB Grader, I am asked whether I am an instructor or student, with a message saying I do not yet have access. How do I gain access to MATLAB Grader? student, instructor, enroll, sms, license, login, grader, subscription MATLAB Answers — New Questions
Need some help generating White Noise Source
clear all
close all
clc
tic
L=10; %[m] Fiber length
PS=1;
n=1.45;
eps0=8.854e-12; % [F/m] Vacuum permittivity
mu0 = 4*pi*1e-7;%[H/m] Vacuum permeability
c=2.9979e8; % [m/sec] Speed of light
Z0=sqrt(mu0/eps0); %[Ohm] Vacuum impedance
dt = 6e-12; dz=dt*c/n; %Spacial and Temporal step sizes.
%dz=2.5e-4;
Fs=1/dt;
N=round(L/dz); % Fiber length discretization
T=10*2*L*n/c; %time taken for 10 round trips
Nt=round(T/dt);
%% material characteristics
A=80e-12; %[m^2] fiber’s effective area
I1_0=PS/A;
% figure;
FA=(-Nt/2:Nt/2-1)*Fs/Nt;
fc=3e9;
X = randn(1,Nt); %random noise generation
Y1 = 10*lowpass(X, fc, Fs, Steepness=0.8);
ypm1 = 1.2743e+06*exp(1i*Y1);
figure;
plot(FA,abs(fftshift(fft(Y1/Nt))));
xlim([-20e9 20
e9]);
figure;
semilogy(FA,(2*n*c*eps0*A*abs(fftshift(fft(ypm1/Nt).^2))))
I am trying to generate White noise source for my phase modulation technique.
The procedure is to pass the signal through a rectangular band filter to imprint the sinc envelope onto the waveform.
Likewise I have generated random noise and passed through low pass filter of 3GHz but the fft of the product is not upto the figure.
Can anyone suggest any changes.clear all
close all
clc
tic
L=10; %[m] Fiber length
PS=1;
n=1.45;
eps0=8.854e-12; % [F/m] Vacuum permittivity
mu0 = 4*pi*1e-7;%[H/m] Vacuum permeability
c=2.9979e8; % [m/sec] Speed of light
Z0=sqrt(mu0/eps0); %[Ohm] Vacuum impedance
dt = 6e-12; dz=dt*c/n; %Spacial and Temporal step sizes.
%dz=2.5e-4;
Fs=1/dt;
N=round(L/dz); % Fiber length discretization
T=10*2*L*n/c; %time taken for 10 round trips
Nt=round(T/dt);
%% material characteristics
A=80e-12; %[m^2] fiber’s effective area
I1_0=PS/A;
% figure;
FA=(-Nt/2:Nt/2-1)*Fs/Nt;
fc=3e9;
X = randn(1,Nt); %random noise generation
Y1 = 10*lowpass(X, fc, Fs, Steepness=0.8);
ypm1 = 1.2743e+06*exp(1i*Y1);
figure;
plot(FA,abs(fftshift(fft(Y1/Nt))));
xlim([-20e9 20
e9]);
figure;
semilogy(FA,(2*n*c*eps0*A*abs(fftshift(fft(ypm1/Nt).^2))))
I am trying to generate White noise source for my phase modulation technique.
The procedure is to pass the signal through a rectangular band filter to imprint the sinc envelope onto the waveform.
Likewise I have generated random noise and passed through low pass filter of 3GHz but the fft of the product is not upto the figure.
Can anyone suggest any changes. clear all
close all
clc
tic
L=10; %[m] Fiber length
PS=1;
n=1.45;
eps0=8.854e-12; % [F/m] Vacuum permittivity
mu0 = 4*pi*1e-7;%[H/m] Vacuum permeability
c=2.9979e8; % [m/sec] Speed of light
Z0=sqrt(mu0/eps0); %[Ohm] Vacuum impedance
dt = 6e-12; dz=dt*c/n; %Spacial and Temporal step sizes.
%dz=2.5e-4;
Fs=1/dt;
N=round(L/dz); % Fiber length discretization
T=10*2*L*n/c; %time taken for 10 round trips
Nt=round(T/dt);
%% material characteristics
A=80e-12; %[m^2] fiber’s effective area
I1_0=PS/A;
% figure;
FA=(-Nt/2:Nt/2-1)*Fs/Nt;
fc=3e9;
X = randn(1,Nt); %random noise generation
Y1 = 10*lowpass(X, fc, Fs, Steepness=0.8);
ypm1 = 1.2743e+06*exp(1i*Y1);
figure;
plot(FA,abs(fftshift(fft(Y1/Nt))));
xlim([-20e9 20
e9]);
figure;
semilogy(FA,(2*n*c*eps0*A*abs(fftshift(fft(ypm1/Nt).^2))))
I am trying to generate White noise source for my phase modulation technique.
The procedure is to pass the signal through a rectangular band filter to imprint the sinc envelope onto the waveform.
Likewise I have generated random noise and passed through low pass filter of 3GHz but the fft of the product is not upto the figure.
Can anyone suggest any changes. wns, fft, sinc MATLAB Answers — New Questions
How can I understand that my program is running or not?
My one matlab program is running. It is not showing any error, but taking too long time. I have checked it with breakpoints. Is there any way to understand that Matlab is running or not?My one matlab program is running. It is not showing any error, but taking too long time. I have checked it with breakpoints. Is there any way to understand that Matlab is running or not? My one matlab program is running. It is not showing any error, but taking too long time. I have checked it with breakpoints. Is there any way to understand that Matlab is running or not? about running status of matlab program MATLAB Answers — New Questions
BusSelector InputSignals computation time exploses (M2016b->M2022b)
Hello,
I’m testing a MATLAB script on a SIMULMINK model made of 1727 models, migrated from M2016b environment to M2022b environment.
The purpose of the script is to build a predecessor list for each model while analyzing the connections of the signals.
I’ve noticed the computation time to retrieve the list of input signals from BusSelector blocks has highly increased from M20163b to M2022b
With profiler, the following function
bus = get_param(handle, ‘InputSignals’);
can take 70-90 sec sometimes whereas it was never exceeding 1s before (M2016b).
Please see the screenshots from profiler
Is there any reason why this computation time can increase so much, and what king of workaround can I test.
As I’m analyzing the list of predecessors from each model inports, if I find a busSelector, I’m analyzing the signal names to compute the indexes within the bus structure where my signal is located in order to apply the same indexes when I meet the corresponding BusCreator blocks to continue the ascending propagation analysis.Hello,
I’m testing a MATLAB script on a SIMULMINK model made of 1727 models, migrated from M2016b environment to M2022b environment.
The purpose of the script is to build a predecessor list for each model while analyzing the connections of the signals.
I’ve noticed the computation time to retrieve the list of input signals from BusSelector blocks has highly increased from M20163b to M2022b
With profiler, the following function
bus = get_param(handle, ‘InputSignals’);
can take 70-90 sec sometimes whereas it was never exceeding 1s before (M2016b).
Please see the screenshots from profiler
Is there any reason why this computation time can increase so much, and what king of workaround can I test.
As I’m analyzing the list of predecessors from each model inports, if I find a busSelector, I’m analyzing the signal names to compute the indexes within the bus structure where my signal is located in order to apply the same indexes when I meet the corresponding BusCreator blocks to continue the ascending propagation analysis. Hello,
I’m testing a MATLAB script on a SIMULMINK model made of 1727 models, migrated from M2016b environment to M2022b environment.
The purpose of the script is to build a predecessor list for each model while analyzing the connections of the signals.
I’ve noticed the computation time to retrieve the list of input signals from BusSelector blocks has highly increased from M20163b to M2022b
With profiler, the following function
bus = get_param(handle, ‘InputSignals’);
can take 70-90 sec sometimes whereas it was never exceeding 1s before (M2016b).
Please see the screenshots from profiler
Is there any reason why this computation time can increase so much, and what king of workaround can I test.
As I’m analyzing the list of predecessors from each model inports, if I find a busSelector, I’m analyzing the signal names to compute the indexes within the bus structure where my signal is located in order to apply the same indexes when I meet the corresponding BusCreator blocks to continue the ascending propagation analysis. busselector, signal processing, time MATLAB Answers — New Questions
Modeling the effect of the reaction wheel moment on the satellite body using SolidWorks and then SimMechanics.
I am modeling the impact of the moment of a reaction wheel mounted on the z-axis on the body of a satellite in Solidworks, and then I want to transfer it to SimMechanics.
The problem is that the moment from the reaction wheel is not transmitted to the satellite body, the wheel rotates at 3000 rpm, but the position of the satellite does not change in any way:
This is due to either the wrong type of mates (I chose concentricity and coincidence) or additional force effects.
The initial coupling is concentric and coincident. Using the Force/Torque Manager in SW, I applied a torque to the wheel and specified the satellite body as the reaction body.
I.e. I managed to generate this motion via Force/Torque PropertyManager in SW. But it’s still not the same. I plan to transfer the model to SimMechanics and set control signals, so the reaction should be defined via mechanical couplings. I don’t know if it will work via forces set via Force/Torque Manager.I am modeling the impact of the moment of a reaction wheel mounted on the z-axis on the body of a satellite in Solidworks, and then I want to transfer it to SimMechanics.
The problem is that the moment from the reaction wheel is not transmitted to the satellite body, the wheel rotates at 3000 rpm, but the position of the satellite does not change in any way:
This is due to either the wrong type of mates (I chose concentricity and coincidence) or additional force effects.
The initial coupling is concentric and coincident. Using the Force/Torque Manager in SW, I applied a torque to the wheel and specified the satellite body as the reaction body.
I.e. I managed to generate this motion via Force/Torque PropertyManager in SW. But it’s still not the same. I plan to transfer the model to SimMechanics and set control signals, so the reaction should be defined via mechanical couplings. I don’t know if it will work via forces set via Force/Torque Manager. I am modeling the impact of the moment of a reaction wheel mounted on the z-axis on the body of a satellite in Solidworks, and then I want to transfer it to SimMechanics.
The problem is that the moment from the reaction wheel is not transmitted to the satellite body, the wheel rotates at 3000 rpm, but the position of the satellite does not change in any way:
This is due to either the wrong type of mates (I chose concentricity and coincidence) or additional force effects.
The initial coupling is concentric and coincident. Using the Force/Torque Manager in SW, I applied a torque to the wheel and specified the satellite body as the reaction body.
I.e. I managed to generate this motion via Force/Torque PropertyManager in SW. But it’s still not the same. I plan to transfer the model to SimMechanics and set control signals, so the reaction should be defined via mechanical couplings. I don’t know if it will work via forces set via Force/Torque Manager. solidworks, simmechanics, motion study, dynamic, simulink, control MATLAB Answers — New Questions
How to connect XCP on CAN through Simulink model on Simulink Real-time?
I want to connect my model to a2l variables in my test ECU through XCP on CAN. My XCP transmit address is 0x200 and XCP receive address is 0x300. I do not understand how to use the XCP Transport Layer block from Simulink Real-time.
I have created a model using the blocks shown in the Screenshot. However, I get errors shown in the attached images when I run the model – MAX_CTO from the Connect response (80) and MAX_DTO from the Connect response (2) does not match the value from the A2L (8). I’m not sure if there are any other settings to be configured in the model.I want to connect my model to a2l variables in my test ECU through XCP on CAN. My XCP transmit address is 0x200 and XCP receive address is 0x300. I do not understand how to use the XCP Transport Layer block from Simulink Real-time.
I have created a model using the blocks shown in the Screenshot. However, I get errors shown in the attached images when I run the model – MAX_CTO from the Connect response (80) and MAX_DTO from the Connect response (2) does not match the value from the A2L (8). I’m not sure if there are any other settings to be configured in the model. I want to connect my model to a2l variables in my test ECU through XCP on CAN. My XCP transmit address is 0x200 and XCP receive address is 0x300. I do not understand how to use the XCP Transport Layer block from Simulink Real-time.
I have created a model using the blocks shown in the Screenshot. However, I get errors shown in the attached images when I run the model – MAX_CTO from the Connect response (80) and MAX_DTO from the Connect response (2) does not match the value from the A2L (8). I’m not sure if there are any other settings to be configured in the model. xcp on can, xcp can transport layer block, ecu a2l read and write MATLAB Answers — New Questions
Using chi2gof to test two distributions
I want to use the chi2gof to test if two distributions come from a common distribution (null hypothesis) or if they do not come from a common distribution (alternative hypothesis). I have binned observational data (x), binned model data (y), and the bin edges (bins). Both the observational and model data are counts per bin.
x= [41 22 11 10 9 5 2 3 2]
y= [38.052 24.2655 15.4665 9.8595 6.2895 4.011 2.562 1.6275 2.8665]
bins=[0:9:81]
Because the data is already binned and because I’m testing x against y, I used the following code
[h,p,stat]=chi2gof(x,’Edges’,bins,’Expected’,y)
Manual calculation of the chi2 test statistic results in 4.6861 with a probablity of p=.7905. The above function however, produces a very different result. The resulting stats show different bin edges than designated, the ovserved counts per bin do not match x, the chi2 test statistic is ~87, and p<0.001. Could someone please explain why I’m getting such dramatically different results?I want to use the chi2gof to test if two distributions come from a common distribution (null hypothesis) or if they do not come from a common distribution (alternative hypothesis). I have binned observational data (x), binned model data (y), and the bin edges (bins). Both the observational and model data are counts per bin.
x= [41 22 11 10 9 5 2 3 2]
y= [38.052 24.2655 15.4665 9.8595 6.2895 4.011 2.562 1.6275 2.8665]
bins=[0:9:81]
Because the data is already binned and because I’m testing x against y, I used the following code
[h,p,stat]=chi2gof(x,’Edges’,bins,’Expected’,y)
Manual calculation of the chi2 test statistic results in 4.6861 with a probablity of p=.7905. The above function however, produces a very different result. The resulting stats show different bin edges than designated, the ovserved counts per bin do not match x, the chi2 test statistic is ~87, and p<0.001. Could someone please explain why I’m getting such dramatically different results? I want to use the chi2gof to test if two distributions come from a common distribution (null hypothesis) or if they do not come from a common distribution (alternative hypothesis). I have binned observational data (x), binned model data (y), and the bin edges (bins). Both the observational and model data are counts per bin.
x= [41 22 11 10 9 5 2 3 2]
y= [38.052 24.2655 15.4665 9.8595 6.2895 4.011 2.562 1.6275 2.8665]
bins=[0:9:81]
Because the data is already binned and because I’m testing x against y, I used the following code
[h,p,stat]=chi2gof(x,’Edges’,bins,’Expected’,y)
Manual calculation of the chi2 test statistic results in 4.6861 with a probablity of p=.7905. The above function however, produces a very different result. The resulting stats show different bin edges than designated, the ovserved counts per bin do not match x, the chi2 test statistic is ~87, and p<0.001. Could someone please explain why I’m getting such dramatically different results? chi2gof MATLAB Answers — New Questions
sorting values of a matrix column when the other column has the same value
Hi all,
I have a matrix that has two columns as following:
A = [0.1 0.1 ; 0.1 -0.3 ; 0.1 0.5 ; 0.1 0; 0.1 -0.5; 0.1 -0.1; 0.1 0.4;
0.2 0.1 ; 0.2 -0.3 ; 0.2 0.5 ; 0.2 0; 0.2 -0.5; 0.2 -0.1; 0.2 0.4;
0.3 0.1 ; 0.3 -0.3 ; 0.3 0.5 ; 0.3 0; 0.3 -0.5; 0.3 -0.1; 0.3 0.4];
And I want to sort the second column of this matrix for every uniqe value of the first column so that the result looks like:
Asorted = [0.1 -0.5 ; 0.1 -0.3 ; 0.1 -0.1 ; 0.1 0; 0.1 0.1; 0.1 0.4; 0.1 0.5;
0.2 -0.5 ; 0.2 -0.3 ; 0.2 -0.1 ; 0.2 0; 0.2 0.1; 0.2 0.4; 0.2 0.5;
0.3 -0.5 ; 0.3 -0.3 ; 0.3 -0.1 ; 0.3 0; 0.3 0.1; 0.3 0.4; 0.3 0.5];
My "failing" attempt of doing this is the following:
A1 = A(:,1); %forst column
A2 = A(:,2); %second column
Auni = unique(A1); %unique value of the first column
for i = 1:size(A,1) %go through all the points in the first column
for j = 1:numel(Auni) %go throguh the unique values of the first column
if A1(i) == Auni(j) %if the point equals one of the uniqe values
[A2 , sortdx] = sort(A2); %sort out the second column of matrix A
A1 = A1(sortidx); %sort the first column accordingly
Asorted = [A1 A2]; %combine both results.
end
end
end
Also, how can I reorder another matrix based on the sorting done previously on matrix ?
Any help would be appreicted.
Thanks.Hi all,
I have a matrix that has two columns as following:
A = [0.1 0.1 ; 0.1 -0.3 ; 0.1 0.5 ; 0.1 0; 0.1 -0.5; 0.1 -0.1; 0.1 0.4;
0.2 0.1 ; 0.2 -0.3 ; 0.2 0.5 ; 0.2 0; 0.2 -0.5; 0.2 -0.1; 0.2 0.4;
0.3 0.1 ; 0.3 -0.3 ; 0.3 0.5 ; 0.3 0; 0.3 -0.5; 0.3 -0.1; 0.3 0.4];
And I want to sort the second column of this matrix for every uniqe value of the first column so that the result looks like:
Asorted = [0.1 -0.5 ; 0.1 -0.3 ; 0.1 -0.1 ; 0.1 0; 0.1 0.1; 0.1 0.4; 0.1 0.5;
0.2 -0.5 ; 0.2 -0.3 ; 0.2 -0.1 ; 0.2 0; 0.2 0.1; 0.2 0.4; 0.2 0.5;
0.3 -0.5 ; 0.3 -0.3 ; 0.3 -0.1 ; 0.3 0; 0.3 0.1; 0.3 0.4; 0.3 0.5];
My "failing" attempt of doing this is the following:
A1 = A(:,1); %forst column
A2 = A(:,2); %second column
Auni = unique(A1); %unique value of the first column
for i = 1:size(A,1) %go through all the points in the first column
for j = 1:numel(Auni) %go throguh the unique values of the first column
if A1(i) == Auni(j) %if the point equals one of the uniqe values
[A2 , sortdx] = sort(A2); %sort out the second column of matrix A
A1 = A1(sortidx); %sort the first column accordingly
Asorted = [A1 A2]; %combine both results.
end
end
end
Also, how can I reorder another matrix based on the sorting done previously on matrix ?
Any help would be appreicted.
Thanks. Hi all,
I have a matrix that has two columns as following:
A = [0.1 0.1 ; 0.1 -0.3 ; 0.1 0.5 ; 0.1 0; 0.1 -0.5; 0.1 -0.1; 0.1 0.4;
0.2 0.1 ; 0.2 -0.3 ; 0.2 0.5 ; 0.2 0; 0.2 -0.5; 0.2 -0.1; 0.2 0.4;
0.3 0.1 ; 0.3 -0.3 ; 0.3 0.5 ; 0.3 0; 0.3 -0.5; 0.3 -0.1; 0.3 0.4];
And I want to sort the second column of this matrix for every uniqe value of the first column so that the result looks like:
Asorted = [0.1 -0.5 ; 0.1 -0.3 ; 0.1 -0.1 ; 0.1 0; 0.1 0.1; 0.1 0.4; 0.1 0.5;
0.2 -0.5 ; 0.2 -0.3 ; 0.2 -0.1 ; 0.2 0; 0.2 0.1; 0.2 0.4; 0.2 0.5;
0.3 -0.5 ; 0.3 -0.3 ; 0.3 -0.1 ; 0.3 0; 0.3 0.1; 0.3 0.4; 0.3 0.5];
My "failing" attempt of doing this is the following:
A1 = A(:,1); %forst column
A2 = A(:,2); %second column
Auni = unique(A1); %unique value of the first column
for i = 1:size(A,1) %go through all the points in the first column
for j = 1:numel(Auni) %go throguh the unique values of the first column
if A1(i) == Auni(j) %if the point equals one of the uniqe values
[A2 , sortdx] = sort(A2); %sort out the second column of matrix A
A1 = A1(sortidx); %sort the first column accordingly
Asorted = [A1 A2]; %combine both results.
end
end
end
Also, how can I reorder another matrix based on the sorting done previously on matrix ?
Any help would be appreicted.
Thanks. matlab, reorder, rows, matrices, index, indexing, sort MATLAB Answers — New Questions
Embedded Coder qualification for ISO 26262
Please clarify – is the Embedded Coder already certified, or qualified, for ASIL D under ISO26262?
Or are there some steps the user must do to achieve that qualification level?
I can see there is a qualification kit, but it is not clear to me what must be done to complete the qualification, for the Embedded Coder tool.
Appreciate any clarification.Please clarify – is the Embedded Coder already certified, or qualified, for ASIL D under ISO26262?
Or are there some steps the user must do to achieve that qualification level?
I can see there is a qualification kit, but it is not clear to me what must be done to complete the qualification, for the Embedded Coder tool.
Appreciate any clarification. Please clarify – is the Embedded Coder already certified, or qualified, for ASIL D under ISO26262?
Or are there some steps the user must do to achieve that qualification level?
I can see there is a qualification kit, but it is not clear to me what must be done to complete the qualification, for the Embedded Coder tool.
Appreciate any clarification. qualification, embedded coder, iso 26262 MATLAB Answers — New Questions
data{i}=importdata([pathname,filename{i}]);
meaning of this codemeaning of this code meaning of this code started with this code MATLAB Answers — New Questions
gamultiobj does not return a truly nondominated pareto set
Hello guys,
I would like to ask for your help understanding an observation that i made with the gamulitobj solver.
I am running an optimization with 10 variables and a two dimensional fitness function. Inside the fitness function the two scores of all individuals are plotted. All options for the solver are on its default values. I do not modify any data by a custom output function. The fitness function is reproducible, no rng is involved.
After the solver finishes, i call the fitness function again to plot the variables of the pareto set returned by the solver. But the set of variables is not truly nondominated compared to other points in that plot. The solver sometimes returns a point, which should have been dominated by another point during optimization.
I can’t explain this behavior besides having read mostly all of the docs regarding this solver.
I might want to add that the magnitude of the two scores is quite different, see at the axes below. The plot below shows the central part of the pareto set, the black points are plotted during the iterations and the red diamonds with the call to the fitness function after the solver has finished.
I would highly appreciate if you could give my your thoughts or explanations for this behavior or ideas on how tho get only the truly nondominated points.Hello guys,
I would like to ask for your help understanding an observation that i made with the gamulitobj solver.
I am running an optimization with 10 variables and a two dimensional fitness function. Inside the fitness function the two scores of all individuals are plotted. All options for the solver are on its default values. I do not modify any data by a custom output function. The fitness function is reproducible, no rng is involved.
After the solver finishes, i call the fitness function again to plot the variables of the pareto set returned by the solver. But the set of variables is not truly nondominated compared to other points in that plot. The solver sometimes returns a point, which should have been dominated by another point during optimization.
I can’t explain this behavior besides having read mostly all of the docs regarding this solver.
I might want to add that the magnitude of the two scores is quite different, see at the axes below. The plot below shows the central part of the pareto set, the black points are plotted during the iterations and the red diamonds with the call to the fitness function after the solver has finished.
I would highly appreciate if you could give my your thoughts or explanations for this behavior or ideas on how tho get only the truly nondominated points. Hello guys,
I would like to ask for your help understanding an observation that i made with the gamulitobj solver.
I am running an optimization with 10 variables and a two dimensional fitness function. Inside the fitness function the two scores of all individuals are plotted. All options for the solver are on its default values. I do not modify any data by a custom output function. The fitness function is reproducible, no rng is involved.
After the solver finishes, i call the fitness function again to plot the variables of the pareto set returned by the solver. But the set of variables is not truly nondominated compared to other points in that plot. The solver sometimes returns a point, which should have been dominated by another point during optimization.
I can’t explain this behavior besides having read mostly all of the docs regarding this solver.
I might want to add that the magnitude of the two scores is quite different, see at the axes below. The plot below shows the central part of the pareto set, the black points are plotted during the iterations and the red diamonds with the call to the fitness function after the solver has finished.
I would highly appreciate if you could give my your thoughts or explanations for this behavior or ideas on how tho get only the truly nondominated points. genetic algorithm, multiobjective optimization, pareto dominance MATLAB Answers — New Questions
Related to implementation of Maximum Likelihood Detection in MATLAB
Hello all, I am working on research paper in which I have to implement Maximum Likelihood (ML) detection at the receiver. I am interested in plotting Bit error rate (BER) Vs Signal to noise ratio (SNR) plot using semilogy.
Below I am giving the expression of ML detection that I am trying to implement:
— (1)
where is received signal of dimension , is complex Gaussian channel matrix of dimension such that it has zero mean and 10 variance, is transmitted signal such that and each has dimension and is chosen from set , where has dimension and it denotes the GSSK modulated symbol. The GSSK modulated symbol has value 1 at positions and value 0 at the remaining () positions.
Also, and , where denotes the cardinality of a set. To find the optimal solution
of (1), the complexity of exhaustive search over is too high to implement.
My query is that I am not getting how to implement ML detection (eq. (1)) in MATLAB. I am also sharing the MATLAB code that I had developed for received signal which is given as
—-(2)
where is additive white Gaussian noise and has dimension .
Any help in this regard will be highly appreciated.
MATLAB code:
N_t = 4; % number of antennas at tag
N_r = 2; % number of antennas at reader
L = 500; % number of observations
n_t = 2; % number of active antennas in GSSK
% Define the GSSK symbols explicitly
GSSK_symbols = [
1 1 0 0;
1 0 1 0;
1 0 0 1;
0 0 1 1;
];
% Total information bits carried by each symbol
M = floor(log2(nchoosek(N_t, n_t)));
% Number of GSSK symbols
N = 2^M;
for snr = 0:3:21 % This is SNR in dB
% Generate the channel matrix H_tr
H_tr = sqrt(10/2) * (randn(N_r, N_t) + 1i*randn(N_r, N_t));
% Generate the transmitted signal X
X = zeros(N_t, L);
for l = 1:L
symbol_idx = randi(N); % randomly choose a symbol index
X(:, l) = GSSK_symbols(symbol_idx, :).’;
end
% Generate the noise W
W = (randn(N_r, L) + 1i*randn(N_r, L)) / sqrt(2);
% Calculate the received signal Y
Y = H_tr * X + 10^(-snr/20) * W;
endHello all, I am working on research paper in which I have to implement Maximum Likelihood (ML) detection at the receiver. I am interested in plotting Bit error rate (BER) Vs Signal to noise ratio (SNR) plot using semilogy.
Below I am giving the expression of ML detection that I am trying to implement:
— (1)
where is received signal of dimension , is complex Gaussian channel matrix of dimension such that it has zero mean and 10 variance, is transmitted signal such that and each has dimension and is chosen from set , where has dimension and it denotes the GSSK modulated symbol. The GSSK modulated symbol has value 1 at positions and value 0 at the remaining () positions.
Also, and , where denotes the cardinality of a set. To find the optimal solution
of (1), the complexity of exhaustive search over is too high to implement.
My query is that I am not getting how to implement ML detection (eq. (1)) in MATLAB. I am also sharing the MATLAB code that I had developed for received signal which is given as
—-(2)
where is additive white Gaussian noise and has dimension .
Any help in this regard will be highly appreciated.
MATLAB code:
N_t = 4; % number of antennas at tag
N_r = 2; % number of antennas at reader
L = 500; % number of observations
n_t = 2; % number of active antennas in GSSK
% Define the GSSK symbols explicitly
GSSK_symbols = [
1 1 0 0;
1 0 1 0;
1 0 0 1;
0 0 1 1;
];
% Total information bits carried by each symbol
M = floor(log2(nchoosek(N_t, n_t)));
% Number of GSSK symbols
N = 2^M;
for snr = 0:3:21 % This is SNR in dB
% Generate the channel matrix H_tr
H_tr = sqrt(10/2) * (randn(N_r, N_t) + 1i*randn(N_r, N_t));
% Generate the transmitted signal X
X = zeros(N_t, L);
for l = 1:L
symbol_idx = randi(N); % randomly choose a symbol index
X(:, l) = GSSK_symbols(symbol_idx, :).’;
end
% Generate the noise W
W = (randn(N_r, L) + 1i*randn(N_r, L)) / sqrt(2);
% Calculate the received signal Y
Y = H_tr * X + 10^(-snr/20) * W;
end Hello all, I am working on research paper in which I have to implement Maximum Likelihood (ML) detection at the receiver. I am interested in plotting Bit error rate (BER) Vs Signal to noise ratio (SNR) plot using semilogy.
Below I am giving the expression of ML detection that I am trying to implement:
— (1)
where is received signal of dimension , is complex Gaussian channel matrix of dimension such that it has zero mean and 10 variance, is transmitted signal such that and each has dimension and is chosen from set , where has dimension and it denotes the GSSK modulated symbol. The GSSK modulated symbol has value 1 at positions and value 0 at the remaining () positions.
Also, and , where denotes the cardinality of a set. To find the optimal solution
of (1), the complexity of exhaustive search over is too high to implement.
My query is that I am not getting how to implement ML detection (eq. (1)) in MATLAB. I am also sharing the MATLAB code that I had developed for received signal which is given as
—-(2)
where is additive white Gaussian noise and has dimension .
Any help in this regard will be highly appreciated.
MATLAB code:
N_t = 4; % number of antennas at tag
N_r = 2; % number of antennas at reader
L = 500; % number of observations
n_t = 2; % number of active antennas in GSSK
% Define the GSSK symbols explicitly
GSSK_symbols = [
1 1 0 0;
1 0 1 0;
1 0 0 1;
0 0 1 1;
];
% Total information bits carried by each symbol
M = floor(log2(nchoosek(N_t, n_t)));
% Number of GSSK symbols
N = 2^M;
for snr = 0:3:21 % This is SNR in dB
% Generate the channel matrix H_tr
H_tr = sqrt(10/2) * (randn(N_r, N_t) + 1i*randn(N_r, N_t));
% Generate the transmitted signal X
X = zeros(N_t, L);
for l = 1:L
symbol_idx = randi(N); % randomly choose a symbol index
X(:, l) = GSSK_symbols(symbol_idx, :).’;
end
% Generate the noise W
W = (randn(N_r, L) + 1i*randn(N_r, L)) / sqrt(2);
% Calculate the received signal Y
Y = H_tr * X + 10^(-snr/20) * W;
end digital signal processing, simulation, maximum likelihood MATLAB Answers — New Questions