Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
164 changes: 164 additions & 0 deletions Matlab_ChannelCapacity.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,164 @@
function [output] = Matlab_ChannelCapacity(input)
% NOTE: the outputs that are returned
% MUST be in the same order as registered

% NOTE: Please DO NOT change anything above or below the USER MODEL AREA.
%
% This example shows static output parameters, but these parameters
% may change value at each time step.

switch input.method

case 'register'
% register output variables
PluginConstraintValue = {'ArgumentName','PluginConstraintValue',...
'Name','PluginConstraintValue',...
'ArgumentType','Output'};

% register input variables

DateUTC = {'ArgumentName','DateUTC',...
'Name','DateUTC',...
'ArgumentType','Input'};

EpochSec = {'ArgumentName','EpochSec',...
'Name','EpochSec',...
'ArgumentType','Input'};

CbName = {'ArgumentName','CbName',...
'Name','CbName',...
'ArgumentType','Input'};

ReceiverPath = {'ArgumentName','ReceiverPath',...
'Name','ReceiverPath',...
'ArgumentType','Input'};

RcvrPosCBF = {'ArgumentName','RcvrPosCBF',...
'Name','RcvrPosCBF',...
'ArgumentType','Input'};

RcvrAttitude = {'ArgumentName','RcvrAttitude',...
'Name','RcvrAttitude',...
'ArgumentType','Input'};

TransmitterPath = {'ArgumentName','TransmitterPath',...
'Name','ReceiverPath',...
'ArgumentType','Input'};

XmtrPosCBF= {'ArgumentName','XmtrPosCBF',...
'Name','XmtrPosCBF',...
'ArgumentType','Input'};

XmtrAttitude = {'ArgumentName','XmtrAttitude',...
'Name','XmtrAttitude',...
'ArgumentType','Input'};

ReceivedFrequency = {'ArgumentName','ReceivedFrequency',...
'Name','ReceivedFrequency',...
'ArgumentType','Input'};

DataRate = {'ArgumentName','DataRate',...
'Name','DataRate',...
'ArgumentType','Input'};

Bandwidth = {'ArgumentName','Bandwidth',...
'Name','Bandwidth',...
'ArgumentType','Input'};

CDMAGainValue = {'ArgumentName','CDMAGainValue',...
'Name','CDMAGainValue',...
'ArgumentType','Input'};

ReceiverGain = {'ArgumentName','ReceiverGain',...
'Name','ReceiverGain',...
'ArgumentType','Input'};

PolEfficiency = {'ArgumentName','PolEfficiency',...
'Name','PolEfficiency',...
'ArgumentType','Input'};

PolRelativeAngle = {'ArgumentName','PolRelativeAngle',...
'Name','PolRelativeAngle',...
'ArgumentType','Input'};

RIP = {'ArgumentName','RIP',...
'Name','RIP',...
'ArgumentType','Input'};

FluxDensity = {'ArgumentName','FluxDensity',...
'Name','FluxDensity',...
'ArgumentType','Input'};

GOverT = {'ArgumentName','GOverT',...
'Name','GOverT',...
'ArgumentType','Input'};

CarrierPower = {'ArgumentName','CarrierPower',...
'Name','CarrierPower',...
'ArgumentType','Input'};

BandwidthOverlap = {'ArgumentName','BandwidthOverlap',...
'Name','BandwidthOverlap',...
'ArgumentType','Input'};

CNo = {'ArgumentName','CNo',...
'Name','CNo',...
'ArgumentType','Input'};

CNR = {'ArgumentName','CNR',...
'Name','CNR',...
'ArgumentType','Input'};

EbNo = {'ArgumentName','EbNo',...
'Name','EbNo',...
'ArgumentType','Input'};

BER = {'ArgumentName','BER',...
'Name','BER',...
'ArgumentType','Input'};

output = {PluginConstraintValue,...
DateUTC, EpochSec, CbName, ReceiverPath, TransmitterPath,...
RcvrPosCBF, RcvrAttitude, XmtrPosCBF, XmtrAttitude,...
ReceivedFrequency, DataRate, Bandwidth, CDMAGainValue, ReceiverGain,...
PolEfficiency, PolRelativeAngle, RIP, FluxDensity, GOverT, CarrierPower,...
BandwidthOverlap, CNo, CNR, EbNo, BER};

case 'compute'

computeData = input.methodData;

% compute the Test Model :
% Example Model for testing only
% CommConstraint input & output parameter usage is shown
%

% USER CommConstraint MODEL AREA.

% Channel Capacity is the tight upper bound on the (data) rate at which information can be
% reliably transmitted over a communications channel given by the following:
% C (MBPS) = B (MHz) x log2(1 + S/N);
% S/N can be interchanged C/N which is a power ratio (not in dB).

time = computeData.EpochSec;

xmtrPos = computeData.XmtrPosCBF;
rcvrPos = computeData.RcvrPosCBF;
BW = computeData.Bandwidth;
CN = computeData.CNR;

range = norm(xmtrPos - rcvrPos)/1000;

cnratio = 10^(0.1*CN);
R = (1+cnratio);
L = log2(R);
C = BW*L;

output.PluginConstraintValue = C*1e-6;

% END OF USER MODEL AREA

otherwise
output = [];
end