Skip to content

Instantly share code, notes, and snippets.

@scivision
Created December 15, 2025 01:29
Show Gist options
  • Select an option

  • Save scivision/d7c38cd21fcebd6f1bdf1befe8158728 to your computer and use it in GitHub Desktop.

Select an option

Save scivision/d7c38cd21fcebd6f1bdf1befe8158728 to your computer and use it in GitHub Desktop.
SSB modulation and demodulation without using Matlab without using toolboxes.
Model {
Name "am_env"
Version 7.7
MdlSubVersion 0
GraphicalInterface {
NumRootInports 0
NumRootOutports 0
ParameterArgumentNames ""
ComputedModelVersion "1.1"
NumModelReferences 0
NumTestPointedSignals 0
}
SavedCharacterEncoding "windows-1252"
SaveDefaultBlockParams on
ScopeRefreshTime 0.035000
OverrideScopeRefreshTime on
DisableAllScopes off
DataTypeOverride "UseLocalSettings"
DataTypeOverrideAppliesTo "AllNumericTypes"
MinMaxOverflowLogging "UseLocalSettings"
MinMaxOverflowArchiveMode "Overwrite"
MaxMDLFileLineLength 120
Created "Thu Sep 01 19:03:38 2011"
Creator "User"
UpdateHistory "UpdateHistoryNever"
ModifiedByFormat "%<Auto>"
LastModifiedBy "User"
ModifiedDateFormat "%<Auto>"
LastModifiedDate "Thu Sep 01 19:04:23 2011"
RTWModifiedTimeStamp 236804618
ModelVersionFormat "1.%<AutoIncrement:1>"
ConfigurationManager "None"
SampleTimeColors off
SampleTimeAnnotations off
LibraryLinkDisplay "none"
WideLines off
ShowLineDimensions off
ShowPortDataTypes off
ShowLoopsOnError on
IgnoreBidirectionalLines off
ShowStorageClass off
ShowTestPointIcons on
ShowSignalResolutionIcons on
ShowViewerIcons on
SortedOrder off
ExecutionContextIcon off
ShowLinearizationAnnotations on
BlockNameDataTip off
BlockParametersDataTip off
BlockDescriptionStringDataTip off
ToolBar on
StatusBar on
BrowserShowLibraryLinks off
BrowserLookUnderMasks off
SimulationMode "normal"
LinearizationMsg "none"
Profile off
ParamWorkspaceSource "MATLABWorkspace"
AccelSystemTargetFile "accel.tlc"
AccelTemplateMakefile "accel_default_tmf"
AccelMakeCommand "make_rtw"
TryForcingSFcnDF off
RecordCoverage off
CovPath "/"
CovSaveName "covdata"
CovMetricSettings "dw"
CovNameIncrementing off
CovHtmlReporting on
CovForceBlockReductionOff on
covSaveCumulativeToWorkspaceVar on
CovSaveSingleToWorkspaceVar on
CovCumulativeVarName "covCumulativeData"
CovCumulativeReport off
CovReportOnPause on
CovModelRefEnable "Off"
CovExternalEMLEnable off
ExtModeBatchMode off
ExtModeEnableFloating on
ExtModeTrigType "manual"
ExtModeTrigMode "normal"
ExtModeTrigPort "1"
ExtModeTrigElement "any"
ExtModeTrigDuration 1000
ExtModeTrigDurationFloating "auto"
ExtModeTrigHoldOff 0
ExtModeTrigDelay 0
ExtModeTrigDirection "rising"
ExtModeTrigLevel 0
ExtModeArchiveMode "off"
ExtModeAutoIncOneShot off
ExtModeIncDirWhenArm off
ExtModeAddSuffixToVar off
ExtModeWriteAllDataToWs off
ExtModeArmWhenConnect on
ExtModeSkipDownloadWhenConnect off
ExtModeLogAll on
ExtModeAutoUpdateStatusClock on
BufferReuse on
ShowModelReferenceBlockVersion off
ShowModelReferenceBlockIO off
Array {
Type "Handle"
Dimension 1
Simulink.ConfigSet {
$ObjectID 1
Version "1.11.0"
Array {
Type "Handle"
Dimension 8
Simulink.SolverCC {
$ObjectID 2
Version "1.11.0"
StartTime "0.0"
StopTime "1000"
AbsTol "1e-3"
FixedStep "auto"
InitialStep "auto"
MaxNumMinSteps "-1"
MaxOrder 5
ZcThreshold "auto"
ConsecutiveZCsStepRelTol "10*128*eps"
MaxConsecutiveZCs "1000"
ExtrapolationOrder 4
NumberNewtonIterations 1
MaxStep ".01"
MinStep "auto"
MaxConsecutiveMinStep "1"
RelTol "1e-3"
SolverMode "SingleTasking"
ConcurrentTasks off
Solver "ode45"
SolverName "ode45"
SolverJacobianMethodControl "auto"
ShapePreserveControl "DisableAll"
ZeroCrossControl "UseLocalSettings"
ZeroCrossAlgorithm "Nonadaptive"
AlgebraicLoopSolver "TrustRegion"
SolverResetMethod "Fast"
PositivePriorityOrder off
AutoInsertRateTranBlk off
SampleTimeConstraint "Unconstrained"
InsertRTBMode "Whenever possible"
}
Simulink.DataIOCC {
$ObjectID 3
Version "1.11.0"
Decimation "1"
ExternalInput "[t, u]"
FinalStateName "xFinal"
InitialState "xInitial"
LimitDataPoints off
MaxDataPoints "1000"
LoadExternalInput off
LoadInitialState off
SaveFinalState off
SaveCompleteFinalSimState off
SaveFormat "Array"
SignalLoggingSaveFormat "ModelDataLogs"
SaveOutput off
SaveState off
SignalLogging on
DSMLogging on
InspectSignalLogs off
SaveTime off
ReturnWorkspaceOutputs off
StateSaveName "xout"
TimeSaveName "tout"
OutputSaveName "yout"
SignalLoggingName "logsout"
DSMLoggingName "dsmout"
OutputOption "RefineOutputTimes"
OutputTimes "[]"
ReturnWorkspaceOutputsName "out"
Refine "1"
}
Simulink.OptimizationCC {
$ObjectID 4
Version "1.11.0"
Array {
Type "Cell"
Dimension 8
Cell "BooleansAsBitfields"
Cell "PassReuseOutputArgsAs"
Cell "PassReuseOutputArgsThreshold"
Cell "ZeroExternalMemoryAtStartup"
Cell "ZeroInternalMemoryAtStartup"
Cell "OptimizeModelRefInitCode"
Cell "NoFixptDivByZeroProtection"
Cell "UseSpecifiedMinMax"
PropName "DisabledProps"
}
BlockReduction off
BooleanDataType off
ConditionallyExecuteInputs on
InlineParams off
UseIntDivNetSlope off
UseSpecifiedMinMax off
InlineInvariantSignals off
OptimizeBlockIOStorage on
BufferReuse on
EnhancedBackFolding off
StrengthReduction off
ExpressionFolding on
BooleansAsBitfields off
BitfieldContainerType "uint_T"
EnableMemcpy on
MemcpyThreshold 64
PassReuseOutputArgsAs "Structure reference"
ExpressionDepthLimit 2147483647
FoldNonRolledExpr on
LocalBlockOutputs on
RollThreshold 5
SystemCodeInlineAuto off
StateBitsets off
DataBitsets off
UseTempVars off
ZeroExternalMemoryAtStartup on
ZeroInternalMemoryAtStartup on
InitFltsAndDblsToZero off
NoFixptDivByZeroProtection off
EfficientFloat2IntCast off
EfficientMapNaN2IntZero on
OptimizeModelRefInitCode off
LifeSpan "inf"
MaxStackSize "Inherit from target"
BufferReusableBoundary on
SimCompilerOptimization "Off"
AccelVerboseBuild off
AccelParallelForEachSubsystem on
}
Simulink.DebuggingCC {
$ObjectID 5
Version "1.11.0"
RTPrefix "error"
ConsistencyChecking "none"
ArrayBoundsChecking "none"
SignalInfNanChecking "none"
SignalRangeChecking "none"
ReadBeforeWriteMsg "UseLocalSettings"
WriteAfterWriteMsg "UseLocalSettings"
WriteAfterReadMsg "UseLocalSettings"
AlgebraicLoopMsg "warning"
ArtificialAlgebraicLoopMsg "warning"
SaveWithDisabledLinksMsg "warning"
SaveWithParameterizedLinksMsg "none"
CheckSSInitialOutputMsg on
UnderspecifiedInitializationDetection "Classic"
MergeDetectMultiDrivingBlocksExec "none"
CheckExecutionContextPreStartOutputMsg off
CheckExecutionContextRuntimeOutputMsg off
SignalResolutionControl "TryResolveAllWithWarning"
BlockPriorityViolationMsg "warning"
MinStepSizeMsg "warning"
TimeAdjustmentMsg "none"
MaxConsecutiveZCsMsg "error"
MaskedZcDiagnostic "warning"
IgnoredZcDiagnostic "warning"
SolverPrmCheckMsg "none"
InheritedTsInSrcMsg "warning"
DiscreteInheritContinuousMsg "warning"
MultiTaskDSMMsg "warning"
MultiTaskCondExecSysMsg "none"
MultiTaskRateTransMsg "error"
SingleTaskRateTransMsg "none"
TasksWithSamePriorityMsg "warning"
SigSpecEnsureSampleTimeMsg "warning"
CheckMatrixSingularityMsg "none"
IntegerOverflowMsg "warning"
Int32ToFloatConvMsg "warning"
ParameterDowncastMsg "error"
ParameterOverflowMsg "error"
ParameterUnderflowMsg "none"
ParameterPrecisionLossMsg "warning"
ParameterTunabilityLossMsg "warning"
FixptConstUnderflowMsg "none"
FixptConstOverflowMsg "none"
FixptConstPrecisionLossMsg "none"
UnderSpecifiedDataTypeMsg "none"
UnnecessaryDatatypeConvMsg "none"
VectorMatrixConversionMsg "none"
InvalidFcnCallConnMsg "error"
FcnCallInpInsideContextMsg "Use local settings"
SignalLabelMismatchMsg "none"
UnconnectedInputMsg "warning"
UnconnectedOutputMsg "warning"
UnconnectedLineMsg "warning"
SFcnCompatibilityMsg "none"
UniqueDataStoreMsg "none"
BusObjectLabelMismatch "warning"
RootOutportRequireBusObject "warning"
AssertControl "UseLocalSettings"
EnableOverflowDetection off
ModelReferenceIOMsg "none"
ModelReferenceMultiInstanceNormalModeStructChecksumCheck "error"
ModelReferenceVersionMismatchMessage "none"
ModelReferenceIOMismatchMessage "none"
ModelReferenceCSMismatchMessage "none"
UnknownTsInhSupMsg "warning"
ModelReferenceDataLoggingMessage "warning"
ModelReferenceSymbolNameMessage "warning"
ModelReferenceExtraNoncontSigs "error"
StateNameClashWarn "warning"
SimStateInterfaceChecksumMismatchMsg "warning"
SimStateOlderReleaseMsg "error"
InitInArrayFormatMsg "warning"
StrictBusMsg "None"
BusNameAdapt "WarnAndRepair"
NonBusSignalsTreatedAsBus "none"
LoggingUnavailableSignals "error"
BlockIODiagnostic "none"
SFUnusedDataAndEventsDiag "warning"
SFUnexpectedBacktrackingDiag "warning"
SFInvalidInputDataAccessInChartInitDiag "warning"
SFNoUnconditionalDefaultTransitionDiag "warning"
SFTransitionOutsideNaturalParentDiag "warning"
}
Simulink.HardwareCC {
$ObjectID 6
Version "1.11.0"
ProdBitPerChar 8
ProdBitPerShort 16
ProdBitPerInt 32
ProdBitPerLong 32
ProdBitPerFloat 32
ProdBitPerDouble 64
ProdBitPerPointer 32
ProdLargestAtomicInteger "Char"
ProdLargestAtomicFloat "None"
ProdIntDivRoundTo "Undefined"
ProdEndianess "Unspecified"
ProdWordSize 32
ProdShiftRightIntArith on
ProdHWDeviceType "32-bit Generic"
TargetBitPerChar 8
TargetBitPerShort 16
TargetBitPerInt 32
TargetBitPerLong 32
TargetBitPerFloat 32
TargetBitPerDouble 64
TargetBitPerPointer 32
TargetLargestAtomicInteger "Char"
TargetLargestAtomicFloat "None"
TargetShiftRightIntArith on
TargetIntDivRoundTo "Undefined"
TargetEndianess "Unspecified"
TargetWordSize 32
TargetTypeEmulationWarnSuppressLevel 0
TargetPreprocMaxBitsSint 32
TargetPreprocMaxBitsUint 32
TargetHWDeviceType "Specified"
TargetUnknown on
ProdEqTarget on
}
Simulink.ModelReferenceCC {
$ObjectID 7
Version "1.11.0"
UpdateModelReferenceTargets "IfOutOfDateOrStructuralChange"
CheckModelReferenceTargetMessage "error"
EnableParallelModelReferenceBuilds off
ParallelModelReferenceErrorOnInvalidPool on
ParallelModelReferenceMATLABWorkerInit "None"
ModelReferenceNumInstancesAllowed "Multi"
PropagateVarSize "Infer from blocks in model"
ModelReferencePassRootInputsByReference on
ModelReferenceMinAlgLoopOccurrences off
PropagateSignalLabelsOutOfModel off
SupportModelReferenceSimTargetCustomCode off
}
Simulink.SFSimCC {
$ObjectID 8
Version "1.11.0"
SFSimEnableDebug on
SFSimOverflowDetection on
SFSimEcho on
SimBlas on
SimCtrlC on
SimExtrinsic on
SimIntegrity on
SimUseLocalCustomCode off
SimParseCustomCode on
SimBuildMode "sf_incremental_build"
}
Simulink.RTWCC {
$BackupClass "Simulink.RTWCC"
$ObjectID 9
Version "1.11.0"
Array {
Type "Cell"
Dimension 8
Cell "IncludeHyperlinkInReport"
Cell "GenerateTraceInfo"
Cell "GenerateTraceReport"
Cell "GenerateTraceReportSl"
Cell "GenerateTraceReportSf"
Cell "GenerateTraceReportEml"
Cell "GenerateSLWebview"
Cell "GenerateCodeMetricsReport"
PropName "DisabledProps"
}
SystemTargetFile "grt.tlc"
GenCodeOnly off
MakeCommand "make_rtw"
GenerateMakefile on
TemplateMakefile "grt_unix.tmf"
GenerateReport off
SaveLog off
RTWVerbose on
RetainRTWFile off
ProfileTLC off
TLCDebug off
TLCCoverage off
TLCAssert off
ProcessScriptMode "Default"
ConfigurationMode "Optimized"
ConfigAtBuild off
RTWUseLocalCustomCode off
RTWUseSimCustomCode off
IncludeHyperlinkInReport off
LaunchReport off
TargetLang "C"
IncludeBusHierarchyInRTWFileBlockHierarchyMap off
IncludeERTFirstTime on
GenerateTraceInfo off
GenerateTraceReport off
GenerateTraceReportSl off
GenerateTraceReportSf off
GenerateTraceReportEml off
GenerateCodeInfo off
GenerateSLWebview off
GenerateCodeMetricsReport off
RTWCompilerOptimization "Off"
CheckMdlBeforeBuild "Off"
CustomRebuildMode "OnUpdate"
Array {
Type "Handle"
Dimension 2
Simulink.CodeAppCC {
$ObjectID 10
Version "1.11.0"
Array {
Type "Cell"
Dimension 21
Cell "IgnoreCustomStorageClasses"
Cell "IgnoreTestpoints"
Cell "InsertBlockDesc"
Cell "InsertPolySpaceComments"
Cell "SFDataObjDesc"
Cell "MATLABFcnDesc"
Cell "SimulinkDataObjDesc"
Cell "DefineNamingRule"
Cell "SignalNamingRule"
Cell "ParamNamingRule"
Cell "InlinedPrmAccess"
Cell "CustomSymbolStr"
Cell "CustomSymbolStrGlobalVar"
Cell "CustomSymbolStrType"
Cell "CustomSymbolStrField"
Cell "CustomSymbolStrFcn"
Cell "CustomSymbolStrFcnArg"
Cell "CustomSymbolStrBlkIO"
Cell "CustomSymbolStrTmpVar"
Cell "CustomSymbolStrMacro"
Cell "ReqsInCode"
PropName "DisabledProps"
}
ForceParamTrailComments off
GenerateComments on
IgnoreCustomStorageClasses on
IgnoreTestpoints off
IncHierarchyInIds off
MaxIdLength 31
PreserveName off
PreserveNameWithParent off
ShowEliminatedStatement off
IncAutoGenComments off
SimulinkDataObjDesc off
SFDataObjDesc off
MATLABFcnDesc off
IncDataTypeInIds off
MangleLength 1
CustomSymbolStrGlobalVar "$R$N$M"
CustomSymbolStrType "$N$R$M"
CustomSymbolStrField "$N$M"
CustomSymbolStrFcn "$R$N$M$F"
CustomSymbolStrFcnArg "rt$I$N$M"
CustomSymbolStrBlkIO "rtb_$N$M"
CustomSymbolStrTmpVar "$N$M"
CustomSymbolStrMacro "$R$N$M"
DefineNamingRule "None"
ParamNamingRule "None"
SignalNamingRule "None"
InsertBlockDesc off
InsertPolySpaceComments off
SimulinkBlockComments on
MATLABSourceComments off
EnableCustomComments off
InlinedPrmAccess "Literals"
ReqsInCode off
UseSimReservedNames off
}
Simulink.GRTTargetCC {
$BackupClass "Simulink.TargetCC"
$ObjectID 11
Version "1.11.0"
Array {
Type "Cell"
Dimension 16
Cell "GeneratePreprocessorConditionals"
Cell "IncludeMdlTerminateFcn"
Cell "CombineOutputUpdateFcns"
Cell "SuppressErrorStatus"
Cell "ERTCustomFileBanners"
Cell "GenerateSampleERTMain"
Cell "GenerateTestInterfaces"
Cell "ModelStepFunctionPrototypeControlCompliant"
Cell "CPPClassGenCompliant"
Cell "MultiInstanceERTCode"
Cell "PurelyIntegerCode"
Cell "SupportComplex"
Cell "SupportAbsoluteTime"
Cell "SupportContinuousTime"
Cell "SupportNonInlinedSFcns"
Cell "PortableWordSizes"
PropName "DisabledProps"
}
TargetFcnLib "ansi_tfl_table_tmw.mat"
TargetLibSuffix ""
TargetPreCompLibLocation ""
TargetFunctionLibrary "ANSI_C"
UtilityFuncGeneration "Auto"
ERTMultiwordTypeDef "System defined"
FunctionExecutionProfile off
CodeExecutionProfiling off
ERTCodeCoverageTool "None"
ERTMultiwordLength 256
MultiwordLength 2048
GenerateFullHeader on
GenerateSampleERTMain off
GenerateTestInterfaces off
IsPILTarget off
ModelReferenceCompliant on
ParMdlRefBuildCompliant on
CompOptLevelCompliant on
IncludeMdlTerminateFcn on
GeneratePreprocessorConditionals "Disable all"
CombineOutputUpdateFcns off
CombineSignalStateStructs off
SuppressErrorStatus off
ERTFirstTimeCompliant off
IncludeFileDelimiter "Auto"
ERTCustomFileBanners off
SupportAbsoluteTime on
LogVarNameModifier "rt_"
MatFileLogging on
MultiInstanceERTCode off
SupportNonFinite on
SupportComplex on
PurelyIntegerCode off
SupportContinuousTime on
SupportNonInlinedSFcns on
SupportVariableSizeSignals off
EnableShiftOperators on
ParenthesesLevel "Nominal"
PortableWordSizes off
ModelStepFunctionPrototypeControlCompliant off
CPPClassGenCompliant off
AutosarCompliant off
UseMalloc off
ExtMode off
ExtModeStaticAlloc off
ExtModeTesting off
ExtModeStaticAllocSize 1000000
ExtModeTransport 0
ExtModeMexFile "ext_comm"
ExtModeIntrfLevel "Level1"
RTWCAPISignals off
RTWCAPIParams off
RTWCAPIStates off
RTWCAPIRootIO off
GenerateASAP2 off
}
PropName "Components"
}
}
PropName "Components"
}
Name "Configuration"
CurrentDlgPage "Solver"
ConfigPrmDlgPosition [ 520, 225, 1400, 855 ]
}
PropName "ConfigurationSets"
}
Simulink.ConfigSet {
$PropName "ActiveConfigurationSet"
$ObjectID 1
}
BlockDefaults {
ForegroundColor "black"
BackgroundColor "white"
DropShadow off
NamePlacement "normal"
FontName "Helvetica"
FontSize 10
FontWeight "normal"
FontAngle "normal"
ShowName on
BlockRotation 0
BlockMirror off
}
AnnotationDefaults {
HorizontalAlignment "center"
VerticalAlignment "middle"
ForegroundColor "black"
BackgroundColor "white"
DropShadow off
FontName "Helvetica"
FontSize 10
FontWeight "normal"
FontAngle "normal"
UseDisplayTextAsClickCallback off
}
LineDefaults {
FontName "Helvetica"
FontSize 9
FontWeight "normal"
FontAngle "normal"
}
BlockParameterDefaults {
Block {
BlockType Constant
Value "1"
VectorParams1D on
SamplingMode "Sample based"
OutMin "[]"
OutMax "[]"
OutDataTypeStr "Inherit: Inherit from 'Constant value'"
LockScale off
SampleTime "inf"
FramePeriod "inf"
PreserveConstantTs off
}
Block {
BlockType Inport
Port "1"
OutputFunctionCall off
OutMin "[]"
OutMax "[]"
OutDataTypeStr "Inherit: auto"
LockScale off
BusOutputAsStruct off
PortDimensions "-1"
VarSizeSig "Inherit"
SampleTime "-1"
SignalType "auto"
SamplingMode "auto"
LatchByDelayingOutsideSignal off
LatchInputForFeedbackSignals off
Interpolate on
}
Block {
BlockType Outport
Port "1"
OutMin "[]"
OutMax "[]"
OutDataTypeStr "Inherit: auto"
LockScale off
BusOutputAsStruct off
PortDimensions "-1"
VarSizeSig "Inherit"
SampleTime "-1"
SignalType "auto"
SamplingMode "auto"
SourceOfInitialOutputValue "Dialog"
OutputWhenDisabled "held"
InitialOutput "[]"
}
Block {
BlockType Product
Inputs "2"
Multiplication "Element-wise(.*)"
CollapseMode "All dimensions"
CollapseDim "1"
InputSameDT on
OutMin "[]"
OutMax "[]"
OutDataTypeStr "Inherit: Same as first input"
LockScale off
RndMeth "Zero"
SaturateOnIntegerOverflow on
SampleTime "-1"
}
Block {
BlockType S-Function
FunctionName "system"
SFunctionModules "''"
PortCounts "[]"
SFunctionDeploymentMode off
}
Block {
BlockType Sin
SineType "Time based"
TimeSource "Use simulation time"
Amplitude "1"
Bias "0"
Frequency "1"
Phase "0"
Samples "10"
Offset "0"
SampleTime "-1"
VectorParams1D on
}
Block {
BlockType SubSystem
ShowPortLabels "FromPortIcon"
Permissions "ReadWrite"
PermitHierarchicalResolution "All"
TreatAsAtomicUnit off
CheckFcnCallInpInsideContextMsg off
SystemSampleTime "-1"
RTWFcnNameOpts "Auto"
RTWFileNameOpts "Auto"
RTWMemSecFuncInitTerm "Inherit from model"
RTWMemSecFuncExecute "Inherit from model"
RTWMemSecDataConstants "Inherit from model"
RTWMemSecDataInternal "Inherit from model"
RTWMemSecDataParameters "Inherit from model"
SimViewingDevice off
DataTypeOverride "UseLocalSettings"
DataTypeOverrideAppliesTo "AllNumericTypes"
MinMaxOverflowLogging "UseLocalSettings"
Variant off
GeneratePreprocessorConditionals off
}
Block {
BlockType Sum
IconShape "rectangular"
Inputs "++"
CollapseMode "All dimensions"
CollapseDim "1"
InputSameDT on
AccumDataTypeStr "Inherit: Inherit via internal rule"
OutMin "[]"
OutMax "[]"
OutDataTypeStr "Inherit: Same as first input"
LockScale off
RndMeth "Floor"
SaturateOnIntegerOverflow on
SampleTime "-1"
}
Block {
BlockType Switch
Criteria "u2 >= Threshold"
Threshold "0"
InputSameDT on
OutMin "[]"
OutMax "[]"
OutDataTypeStr "Inherit: Inherit via internal rule"
LockScale off
RndMeth "Floor"
SaturateOnIntegerOverflow on
ZeroCross on
SampleTime "-1"
AllowDiffInputSizes off
}
Block {
BlockType TransferFcn
Numerator "[1]"
Denominator "[1 2 1]"
AbsoluteTolerance "auto"
ContinuousStateAttributes "''"
Realization "auto"
}
}
System {
Name "am_env"
Location [26, 471, 677, 771]
Open on
ModelBrowserVisibility off
ModelBrowserWidth 200
ScreenColor "white"
PaperOrientation "landscape"
PaperPositionMode "auto"
PaperType "usletter"
PaperUnits "inches"
TiledPaperMargins [0.500000, 0.500000, 0.500000, 0.500000]
TiledPageScale 1
ShowPageBoundaries off
ZoomFactor "100"
ReportName "simulink-default.rpt"
SIDHighWatermark "21"
Block {
BlockType Sin
Name "Carrier"
SID "1"
Ports [0, 1]
Position [220, 180, 240, 200]
Frequency "10"
}
Block {
BlockType Constant
Name "Constant"
SID "2"
Position [55, 135, 75, 155]
}
Block {
BlockType SubSystem
Name "Envelope"
SID "3"
Ports [1]
Position [495, 136, 525, 174]
CopyFcn "sfuny([],[],[],'CopyBlock')"
DeleteFcn "sfuny([],[],[],'DeleteBlock')"
LoadFcn "sfuny([],[],[],'LoadBlock')"
StartFcn "sfuny([],[],[],'Start')"
StopFcn "sfuny([],[],[],'Stop')"
NameChangeFcn "sfuny([],[],[],'NameChange')"
ShowPortLabels "none"
MinAlgLoopOccurrences off
PropExecContextOutsideSubsystem off
RTWSystemCode "Auto"
FunctionWithSeparateData off
Opaque off
RequestExecContextInheritance off
MaskHideContents off
MaskType "Graph scope."
MaskDescription "Graph scope using MATLAB graph window.\nEnter plotting ranges and line type."
MaskHelp "This block plots to the MATLAB graph window and can be used as an improved version of the Scope"
" block. Look at the m-file sfuny.m to see how it works. This block can take scalar or vector input signal."
MaskPromptString "Time range:|y-min:|y-max:|Line type (rgbw-:*). Seperate each plot by '/':"
MaskStyleString "edit,edit,edit,edit"
MaskVariables "color = @4;"
MaskTunableValueString "on,on,on,on"
MaskCallbackString "|||"
MaskEnableString "on,on,on,on"
MaskVisibilityString "on,on,on,on"
MaskToolTipString "on,on,on,on"
MaskInitialization " ax = [0, @1, @2, @3]; dt = -1;"
MaskDisplay "plot(0,0,100,100,[90,10,10,10,90,90,10],[65,65,90,40,40,90,90],[90,78,69,54,40,31,25,10],[77,"
"60,48,46,56,75,81,84])"
MaskIconFrame on
MaskIconOpaque on
MaskIconRotate "none"
MaskPortRotate "default"
MaskIconUnits "autoscale"
MaskValueString "15|-2.5|2.5|'r-/g--/c-./w:/m*/ro/b+'"
System {
Name "Envelope"
Location [0, 59, 274, 252]
Open off
ModelBrowserVisibility off
ModelBrowserWidth 200
ScreenColor "white"
PaperOrientation "landscape"
PaperPositionMode "auto"
PaperType "usletter"
PaperUnits "inches"
TiledPaperMargins [0.500000, 0.500000, 0.500000, 0.500000]
TiledPageScale 1
ShowPageBoundaries off
ZoomFactor "100"
Block {
BlockType Inport
Name "x"
SID "4"
Position [65, 55, 85, 75]
IconDisplay "Port number"
}
Block {
BlockType S-Function
Name "S-function\nM-file which plots\nlines\n"
SID "5"
Ports [1]
Position [130, 55, 180, 75]
FunctionName "sfuny"
Parameters "ax, color,dt"
EnableBusSupport off
}
Line {
SrcBlock "x"
SrcPort 1
DstBlock "S-function\nM-file which plots\nlines\n"
DstPort 1
}
}
}
Block {
BlockType SubSystem
Name "Envelope Detector"
SID "6"
Ports [1, 1]
Position [390, 129, 420, 181]
ShowPortLabels "none"
MinAlgLoopOccurrences off
PropExecContextOutsideSubsystem off
RTWSystemCode "Auto"
FunctionWithSeparateData off
Opaque off
RequestExecContextInheritance off
MaskHideContents off
System {
Name "Envelope Detector"
Location [308, 192, 688, 345]
Open off
ModelBrowserVisibility off
ModelBrowserWidth 200
ScreenColor "white"
PaperOrientation "landscape"
PaperPositionMode "auto"
PaperType "usletter"
PaperUnits "inches"
TiledPaperMargins [0.500000, 0.500000, 0.500000, 0.500000]
TiledPageScale 1
ShowPageBoundaries off
ZoomFactor "100"
Block {
BlockType Inport
Name "in_1"
SID "7"
Position [55, 45, 75, 65]
IconDisplay "Port number"
}
Block {
BlockType Constant
Name "Constant1"
SID "8"
Position [95, 80, 115, 100]
Value "0"
}
Block {
BlockType Switch
Name "Diode"
SID "9"
Position [140, 49, 170, 81]
}
Block {
BlockType TransferFcn
Name "Transfer Fcn"
SID "10"
Position [215, 48, 270, 82]
Denominator "[1 1]"
}
Block {
BlockType Outport
Name "out_1"
SID "11"
Position [310, 55, 330, 75]
IconDisplay "Port number"
InitialOutput "0"
}
Line {
SrcBlock "in_1"
SrcPort 1
Points [0, 0]
Branch {
Points [20, 0; 0, 10]
DstBlock "Diode"
DstPort 2
}
Branch {
DstBlock "Diode"
DstPort 1
}
}
Line {
SrcBlock "Transfer Fcn"
SrcPort 1
DstBlock "out_1"
DstPort 1
}
Line {
SrcBlock "Constant1"
SrcPort 1
Points [0, -15]
DstBlock "Diode"
DstPort 3
}
Line {
SrcBlock "Diode"
SrcPort 1
DstBlock "Transfer Fcn"
DstPort 1
}
}
}
Block {
BlockType Sin
Name "Message m(t)"
SID "12"
Ports [0, 1]
Position [55, 85, 75, 105]
Frequency ".5"
Phase "1"
}
Block {
BlockType SubSystem
Name "Modulated signal"
SID "13"
Ports [1]
Position [385, 51, 415, 89]
CopyFcn "sfuny([],[],[],'CopyBlock')"
DeleteFcn "sfuny([],[],[],'DeleteBlock')"
LoadFcn "sfuny([],[],[],'LoadBlock')"
StartFcn "sfuny([],[],[],'Start')"
StopFcn "sfuny([],[],[],'Stop')"
NameChangeFcn "sfuny([],[],[],'NameChange')"
ShowPortLabels "none"
MinAlgLoopOccurrences off
PropExecContextOutsideSubsystem off
RTWSystemCode "Auto"
FunctionWithSeparateData off
Opaque off
RequestExecContextInheritance off
MaskHideContents off
MaskType "Graph scope."
MaskDescription "Graph scope using MATLAB graph window.\nEnter plotting ranges and line type."
MaskHelp "This block plots to the MATLAB graph window and can be used as an improved version of the Scope"
" block. Look at the m-file sfuny.m to see how it works. This block can take scalar or vector input signal."
MaskPromptString "Time range:|y-min:|y-max:|Line type (rgbw-:*). Seperate each plot by '/':"
MaskStyleString "edit,edit,edit,edit"
MaskVariables "color = @4;"
MaskTunableValueString "on,on,on,on"
MaskCallbackString "|||"
MaskEnableString "on,on,on,on"
MaskVisibilityString "on,on,on,on"
MaskToolTipString "on,on,on,on"
MaskInitialization " ax = [0, @1, @2, @3]; dt = -1;"
MaskDisplay "plot(0,0,100,100,[90,10,10,10,90,90,10],[65,65,90,40,40,90,90],[90,78,69,54,40,31,25,10],[77,"
"60,48,46,56,75,81,84])"
MaskIconFrame on
MaskIconOpaque on
MaskIconRotate "none"
MaskPortRotate "default"
MaskIconUnits "autoscale"
MaskValueString "15|-2.5|2.5|'r-/g--/c-./w:/m*/ro/b+'"
System {
Name "Modulated signal"
Location [0, 59, 274, 252]
Open off
ModelBrowserVisibility off
ModelBrowserWidth 200
ScreenColor "white"
PaperOrientation "landscape"
PaperPositionMode "auto"
PaperType "usletter"
PaperUnits "inches"
TiledPaperMargins [0.500000, 0.500000, 0.500000, 0.500000]
TiledPageScale 1
ShowPageBoundaries off
ZoomFactor "100"
Block {
BlockType Inport
Name "x"
SID "14"
Position [65, 55, 85, 75]
IconDisplay "Port number"
}
Block {
BlockType S-Function
Name "S-function\nM-file which plots\nlines\n"
SID "15"
Ports [1]
Position [130, 55, 180, 75]
FunctionName "sfuny"
Parameters "ax, color,dt"
EnableBusSupport off
}
Line {
SrcBlock "x"
SrcPort 1
DstBlock "S-function\nM-file which plots\nlines\n"
DstPort 1
}
}
}
Block {
BlockType SubSystem
Name "Plot k m(t)"
SID "16"
Ports [1]
Position [210, 16, 240, 54]
CopyFcn "sfuny([],[],[],'CopyBlock')"
DeleteFcn "sfuny([],[],[],'DeleteBlock')"
LoadFcn "sfuny([],[],[],'LoadBlock')"
StartFcn "sfuny([],[],[],'Start')"
StopFcn "sfuny([],[],[],'Stop')"
NameChangeFcn "sfuny([],[],[],'NameChange')"
ShowPortLabels "none"
MinAlgLoopOccurrences off
PropExecContextOutsideSubsystem off
RTWSystemCode "Auto"
FunctionWithSeparateData off
Opaque off
RequestExecContextInheritance off
MaskHideContents off
MaskType "Graph scope."
MaskDescription "Graph scope using MATLAB graph window.\nEnter plotting ranges and line type."
MaskHelp "This block plots to the MATLAB graph window and can be used as an improved version of the Scope"
" block. Look at the m-file sfuny.m to see how it works. This block can take scalar or vector input signal."
MaskPromptString "Time range:|y-min:|y-max:|Line type (rgbw-:*). Seperate each plot by '/':"
MaskStyleString "edit,edit,edit,edit"
MaskVariables "color = @4;"
MaskTunableValueString "on,on,on,on"
MaskCallbackString "|||"
MaskEnableString "on,on,on,on"
MaskVisibilityString "on,on,on,on"
MaskToolTipString "on,on,on,on"
MaskInitialization " ax = [0, @1, @2, @3]; dt = -1;"
MaskDisplay "plot(0,0,100,100,[90,10,10,10,90,90,10],[65,65,90,40,40,90,90],[90,78,69,54,40,31,25,10],[77,"
"60,48,46,56,75,81,84])"
MaskIconFrame on
MaskIconOpaque on
MaskIconRotate "none"
MaskPortRotate "default"
MaskIconUnits "autoscale"
MaskValueString "15|-2.5|2.5|'r-/g--/c-./w:/m*/ro/b+'"
System {
Name "Plot k m(t)"
Location [0, 59, 274, 252]
Open off
ModelBrowserVisibility off
ModelBrowserWidth 200
ScreenColor "white"
PaperOrientation "landscape"
PaperPositionMode "auto"
PaperType "usletter"
PaperUnits "inches"
TiledPaperMargins [0.500000, 0.500000, 0.500000, 0.500000]
TiledPageScale 1
ShowPageBoundaries off
ZoomFactor "100"
Block {
BlockType Inport
Name "x"
SID "17"
Position [65, 55, 85, 75]
IconDisplay "Port number"
}
Block {
BlockType S-Function
Name "S-function\nM-file which plots\nlines\n"
SID "18"
Ports [1]
Position [130, 55, 180, 75]
FunctionName "sfuny"
Parameters "ax, color,dt"
EnableBusSupport off
}
Line {
SrcBlock "x"
SrcPort 1
DstBlock "S-function\nM-file which plots\nlines\n"
DstPort 1
}
}
}
Block {
BlockType Product
Name "Product"
SID "19"
Ports [2, 1]
Position [295, 143, 325, 167]
}
Block {
BlockType Reference
Name "Slider\nGain"
SID "20"
Ports [1, 1]
Position [115, 80, 160, 110]
LibraryVersion "1.236"
SourceBlock "simulink/Math\nOperations/Slider\nGain"
SourceType "Slider Gain"
ShowPortLabels "FromPortIcon"
SystemSampleTime "-1"
FunctionWithSeparateData off
RTWMemSecFuncInitTerm "Inherit from model"
RTWMemSecFuncExecute "Inherit from model"
RTWMemSecDataConstants "Inherit from model"
RTWMemSecDataInternal "Inherit from model"
RTWMemSecDataParameters "Inherit from model"
GeneratePreprocessorConditionals off
low "0"
gain "0.9"
high "2"
}
Block {
BlockType Sum
Name "Sum"
SID "21"
Ports [2, 1]
Position [220, 90, 240, 110]
}
Line {
SrcBlock "Envelope Detector"
SrcPort 1
DstBlock "Envelope"
DstPort 1
}
Line {
SrcBlock "Product"
SrcPort 1
Points [0, 0]
Branch {
DstBlock "Envelope Detector"
DstPort 1
}
Branch {
Points [0, -85]
DstBlock "Modulated signal"
DstPort 1
}
}
Line {
SrcBlock "Sum"
SrcPort 1
Points [15, 0; 0, 50]
DstBlock "Product"
DstPort 1
}
Line {
SrcBlock "Carrier"
SrcPort 1
Points [35, 0]
DstBlock "Product"
DstPort 2
}
Line {
SrcBlock "Constant"
SrcPort 1
Points [125, 0]
DstBlock "Sum"
DstPort 2
}
Line {
SrcBlock "Message m(t)"
SrcPort 1
DstBlock "Slider\nGain"
DstPort 1
}
Line {
SrcBlock "Slider\nGain"
SrcPort 1
Points [5, 0]
Branch {
Points [10, 0; 0, -60]
DstBlock "Plot k m(t)"
DstPort 1
}
Branch {
DstBlock "Sum"
DstPort 1
}
}
}
}
Model {
Name "am_env_filt"
Version 2.09
SimParamPage Solver
SampleTimeColors off
InvariantConstants off
WideVectorLines off
ShowLineWidths off
PaperOrientation landscape
PaperType usletter
PaperUnits inches
StartTime "0.0"
StopTime "1000"
Solver ode45
RelTol "1e-3"
AbsTol "1e-3"
Refine "1"
MaxStep ".01"
InitialStep "auto"
FixedStep "auto"
MaxOrder 5
OutputOption RefineOutputTimes
OutputTimes "[]"
LoadExternalInput off
ExternalInput "[t, u]"
SaveTime off
TimeSaveName "tout"
SaveState off
StateSaveName "xout"
SaveOutput off
OutputSaveName "yout"
LoadInitialState off
InitialState "xInitial"
SaveFinalState off
FinalStateName "xFinal"
LimitMaxRows off
MaxRows "1000"
Decimation "1"
AlgebraicLoopMsg warning
MinStepSizeMsg warning
UnconnectedInputMsg warning
UnconnectedOutputMsg warning
UnconnectedLineMsg warning
ConsistencyChecking off
ZeroCross on
SimulationMode normal
RTWSystemTargetFile "grt.tlc"
RTWInlineParameters off
RTWRetainRTWFile off
RTWTemplateMakefile "grt_unix.tmf"
RTWMakeCommand "make_rtw"
RTWGenerateCodeOnly off
ExtModeMexFile "ext_comm"
ExtModeBatchMode off
BlockDefaults {
Orientation right
ForegroundColor black
BackgroundColor white
DropShadow off
NamePlacement normal
FontName "Helvetica"
FontSize 10
FontWeight normal
FontAngle normal
ShowName on
}
AnnotationDefaults {
HorizontalAlignment center
VerticalAlignment middle
ForegroundColor black
BackgroundColor white
DropShadow off
FontName "Helvetica"
FontSize 10
FontWeight normal
FontAngle normal
}
LineDefaults {
FontName "Helvetica"
FontSize 9
FontWeight normal
FontAngle normal
}
System {
Name "am_env_filt"
Location [313, 56, 964, 356]
Open on
ScreenColor white
Block {
BlockType Sin
Name "Carrier"
Position [220, 180, 240, 200]
Amplitude "1"
Frequency "10"
Phase "0"
SampleTime "-1"
}
Block {
BlockType ZeroPole
Name "Chebychev Type II\nLP Filter"
Position [465, 129, 525, 181]
Zeros "z"
Poles "p"
Gain "k"
MaskType "cheb2ap"
MaskDescription "Chebyshev type II low pass filter.\n(Requires "
"Signal Processing Toolbox)"
MaskHelp "Analog Chebychev type II low pass filter "
"using MATLAB's cheb2ap command."
MaskPromptString "Cutoff frequency (rad/sec):|Order:|Db ripple "
"down in stopband:"
MaskStyleString "edit,edit,edit"
MaskInitialization "[z,p,k]=cheb2ap(@2,@3); z=@1*z; p=@1*p; k=real(p"
"rod(-p)/prod(-z)); [num,den]=zp2tf(z,p,k); "
"w=logspace(log10(@1/10),log10(10*@1),50); "
"h=freqs(num,den,w); "
MaskDisplay "plot(20*log10(w),20*log10(abs(h)))"
MaskIconFrame on
MaskIconOpaque on
MaskIconRotate none
MaskIconUnits autoscale
MaskValueString "2|2|20"
}
Block {
BlockType Constant
Name "Constant"
Position [55, 135, 75, 155]
Value "1"
}
Block {
BlockType Constant
Name "Constant1"
Position [350, 170, 370, 190]
Value "0"
}
Block {
BlockType Switch
Name "Diode"
Position [395, 139, 425, 171]
Threshold "0"
}
Block {
BlockType SubSystem
Name "Envelope"
Ports [1, 0, 0, 0, 0]
Position [585, 136, 615, 174]
CopyFcn "set_param(gcb,'userdata',[]);"
DeleteFcn "y_tp=get_param(gcb,'userdata');if ishandle(y_tp)"
",delete(y_tp);end"
NameChangeFcn "set(get_param(gcb,'userdata'),'Name',gcb);"
ShowPortLabels off
MaskType "Graph scope."
MaskDescription "Graph scope using MATLAB graph window.\nEnter "
"plotting ranges and line type."
MaskHelp "This block plots to the MATLAB graph window "
"and can be used as an improved version of "
"the Scope block. Look at the m-file sfuny.m "
"to see how it works. This block can take "
"scalar or vector input signal."
MaskPromptString "Time range:|y-min:|y-max:|Line type (rgbw-:*). "
"Seperate each plot by '/':"
MaskStyleString "edit,edit,edit,edit"
MaskInitialization "color = @4; ax = [0, @1, @2, @3]; dt = -1;"
MaskDisplay "plot(0,0,100,100,[90,10,10,10,90,90,10],[65,65,9"
"0,40,40,90,90],[90,78,69,54,40,31,25,10],[77,60,"
"48,46,56,75,81,84])"
MaskIconFrame on
MaskIconOpaque on
MaskIconRotate none
MaskIconUnits autoscale
MaskValueString "15|-2.5|2.5|'r-/g--/c-./w:/m*/ro/b+'"
System {
Name "Envelope"
Location [0, 59, 274, 252]
Open off
ScreenColor white
Block {
BlockType Inport
Name "x"
Position [65, 55, 85, 75]
Port "1"
PortWidth "-1"
SampleTime "-1"
}
Block {
BlockType S-Function
Name "S-function\nM-file which plots\nlines\n"
Ports [1, 0, 0, 0, 0]
Position [130, 55, 180, 75]
FunctionName "sfuny"
Parameters "ax, color,dt"
}
Line {
SrcBlock "x"
SrcPort 1
DstBlock "S-function\nM-file which plots\nlines\n"
DstPort 1
}
}
}
Block {
BlockType Sin
Name "Message m(t)"
Position [55, 85, 75, 105]
Amplitude "1"
Frequency "1"
Phase "1"
SampleTime "-1"
}
Block {
BlockType SubSystem
Name "Modulated signal"
Ports [1, 0, 0, 0, 0]
Position [385, 51, 415, 89]
CopyFcn "set_param(gcb,'userdata',[]);"
DeleteFcn "y_tp=get_param(gcb,'userdata');if ishandle(y_tp)"
",delete(y_tp);end"
NameChangeFcn "set(get_param(gcb,'userdata'),'Name',gcb);"
ShowPortLabels off
MaskType "Graph scope."
MaskDescription "Graph scope using MATLAB graph window.\nEnter "
"plotting ranges and line type."
MaskHelp "This block plots to the MATLAB graph window "
"and can be used as an improved version of "
"the Scope block. Look at the m-file sfuny.m "
"to see how it works. This block can take "
"scalar or vector input signal."
MaskPromptString "Time range:|y-min:|y-max:|Line type (rgbw-:*). "
"Seperate each plot by '/':"
MaskStyleString "edit,edit,edit,edit"
MaskInitialization "color = @4; ax = [0, @1, @2, @3]; dt = -1;"
MaskDisplay "plot(0,0,100,100,[90,10,10,10,90,90,10],[65,65,9"
"0,40,40,90,90],[90,78,69,54,40,31,25,10],[77,60,"
"48,46,56,75,81,84])"
MaskIconFrame on
MaskIconOpaque on
MaskIconRotate none
MaskIconUnits autoscale
MaskValueString "15|-2.5|2.5|'r-/g--/c-./w:/m*/ro/b+'"
System {
Name "Modulated signal"
Location [0, 59, 274, 252]
Open off
ScreenColor white
Block {
BlockType Inport
Name "x"
Position [65, 55, 85, 75]
Port "1"
PortWidth "-1"
SampleTime "-1"
}
Block {
BlockType S-Function
Name "S-function\nM-file which plots\nlines\n"
Ports [1, 0, 0, 0, 0]
Position [130, 55, 180, 75]
FunctionName "sfuny"
Parameters "ax, color,dt"
}
Line {
SrcBlock "x"
SrcPort 1
DstBlock "S-function\nM-file which plots\nlines\n"
DstPort 1
}
}
}
Block {
BlockType SubSystem
Name "Plot k m(t)"
Ports [1, 0, 0, 0, 0]
Position [210, 16, 240, 54]
CopyFcn "set_param(gcb,'userdata',[]);"
DeleteFcn "y_tp=get_param(gcb,'userdata');if ishandle(y_tp)"
",delete(y_tp);end"
NameChangeFcn "set(get_param(gcb,'userdata'),'Name',gcb);"
ShowPortLabels off
MaskType "Graph scope."
MaskDescription "Graph scope using MATLAB graph window.\nEnter "
"plotting ranges and line type."
MaskHelp "This block plots to the MATLAB graph window "
"and can be used as an improved version of "
"the Scope block. Look at the m-file sfuny.m "
"to see how it works. This block can take "
"scalar or vector input signal."
MaskPromptString "Time range:|y-min:|y-max:|Line type (rgbw-:*). "
"Seperate each plot by '/':"
MaskStyleString "edit,edit,edit,edit"
MaskInitialization "color = @4; ax = [0, @1, @2, @3]; dt = -1;"
MaskDisplay "plot(0,0,100,100,[90,10,10,10,90,90,10],[65,65,9"
"0,40,40,90,90],[90,78,69,54,40,31,25,10],[77,60,"
"48,46,56,75,81,84])"
MaskIconFrame on
MaskIconOpaque on
MaskIconRotate none
MaskIconUnits autoscale
MaskValueString "15|-2.5|2.5|'r-/g--/c-./w:/m*/ro/b+'"
System {
Name "Plot k m(t)"
Location [0, 59, 274, 252]
Open off
ScreenColor white
Block {
BlockType Inport
Name "x"
Position [65, 55, 85, 75]
Port "1"
PortWidth "-1"
SampleTime "-1"
}
Block {
BlockType S-Function
Name "S-function\nM-file which plots\nlines\n"
Ports [1, 0, 0, 0, 0]
Position [130, 55, 180, 75]
FunctionName "sfuny"
Parameters "ax, color,dt"
}
Line {
SrcBlock "x"
SrcPort 1
DstBlock "S-function\nM-file which plots\nlines\n"
DstPort 1
}
}
}
Block {
BlockType Product
Name "Product"
Ports [2, 1, 0, 0, 0]
Position [295, 143, 325, 167]
Inputs "2"
}
Block {
BlockType Reference
Name "Slider\nGain"
Ports [1, 1, 0, 0, 0]
Position [115, 80, 160, 110]
SourceBlock "simulink/Linear/Slider\nGain"
SourceType "Slider Gain"
low "0"
gain "0.9"
high "2"
}
Block {
BlockType Sum
Name "Sum"
Ports [2, 1, 0, 0, 0]
Position [220, 90, 240, 110]
Inputs "++"
}
Line {
SrcBlock "Chebychev Type II\nLP Filter"
SrcPort 1
DstBlock "Envelope"
DstPort 1
}
Line {
SrcBlock "Diode"
SrcPort 1
DstBlock "Chebychev Type II\nLP Filter"
DstPort 1
}
Line {
SrcBlock "Constant1"
SrcPort 1
Points [0, -15]
DstBlock "Diode"
DstPort 3
}
Line {
SrcBlock "Product"
SrcPort 1
Points [0, 0]
Branch {
DstBlock "Diode"
DstPort 2
}
Branch {
Points [25, 0; 0, -10]
DstBlock "Diode"
DstPort 1
}
Branch {
Points [0, -85]
DstBlock "Modulated signal"
DstPort 1
}
}
Line {
SrcBlock "Slider\nGain"
SrcPort 1
Points [5, 0]
Branch {
Points [10, 0; 0, -60]
DstBlock "Plot k m(t)"
DstPort 1
}
Branch {
DstBlock "Sum"
DstPort 1
}
}
Line {
SrcBlock "Sum"
SrcPort 1
Points [15, 0; 0, 50]
DstBlock "Product"
DstPort 1
}
Line {
SrcBlock "Carrier"
SrcPort 1
Points [35, 0]
DstBlock "Product"
DstPort 2
}
Line {
SrcBlock "Constant"
SrcPort 1
Points [125, 0]
DstBlock "Sum"
DstPort 2
}
Line {
SrcBlock "Message m(t)"
SrcPort 1
DstBlock "Slider\nGain"
DstPort 1
}
}
}
function SmoothY=fastsmooth(Y,w,type,ends)
% fastsmooth(Y,w,type,ends) smooths vector Y with smooth
% of width w. Version 2.0, May 2008.
% The argument "type" determines the smooth type:
% If type=1, rectangular (sliding-average or boxcar)
% If type=2, triangular (2 passes of sliding-average)
% If type=3, pseudo-Gaussian (3 passes of sliding-average)
% The argument "ends" controls how the "ends" of the signal
% (the first w/2 points and the last w/2 points) are handled.
% If ends=0, the ends are zero. (In this mode the elapsed
% time is independent of the smooth width). The fastest.
% If ends=1, the ends are smoothed with progressively
% smaller smooths the closer to the end. (In this mode the
% elapsed time increases with increasing smooth widths).
% fastsmooth(Y,w,type) smooths with ends=0.
% fastsmooth(Y,w) smooths with type=1 and ends=0.
% Example:
% fastsmooth([1 1 1 10 10 10 1 1 1 1],3)= [0 1 4 7 10 7 4 1 1 0]
% fastsmooth([1 1 1 10 10 10 1 1 1 1],3,1,1)= [1 1 4 7 10 7 4 1 1 1]
% T. C. O'Haver, 2008.
if nargin==2, ends=0; type=1; end
if nargin==3, ends=0; end
switch type
case 1
SmoothY=sa(Y,w,ends);
case 2
SmoothY=sa(sa(Y,w,ends),w,ends);
case 3
SmoothY=sa(sa(sa(Y,w,ends),w,ends),w,ends);
end
function SmoothY=sa(Y,smoothwidth,ends)
w=round(smoothwidth);
SumPoints=sum(Y(1:w));
s=zeros(size(Y));
halfw=round(w/2);
L=length(Y);
for k=1:L-w,
s(k+halfw-1)=SumPoints;
SumPoints=SumPoints-Y(k);
SumPoints=SumPoints+Y(k+w);
end
s(k+halfw)=sum(Y(L-w+1:L));
SmoothY=s./w;
% Taper the ends of the signal if ends=1.
if ends==1,
startpoint=(smoothwidth + 1)/2;
SmoothY(1)=(Y(1)+Y(2))./2;
for k=2:startpoint,
SmoothY(k)=mean(Y(1:(2*k-1)));
SmoothY(L-k+1)=mean(Y(L-2*k+2:L));
end
SmoothY(L)=(Y(L)+Y(L-1))./2;
end
function [RawFFT1, RawFFT2] = mydBfft(TDsamples1,TDsamples2,FFTsize,Fs,title1,OneOrTwo,MaxFreq)
assert(FFTsize>=length(TDsamples1), 'FFT length must be >= to number of time domain samples')
assert(FFTsize>=length(TDsamples2), 'FFT length must be >= to number of time domain samples')
T = FFTsize ./ Fs;
k(1:FFTsize)=-FFTsize/2:FFTsize/2-1; %check for odd/even case****
freqAxis=k(1:FFTsize) ./ T;
RawFFT1=fft(TDsamples1,FFTsize);
ShiftedFFT1=fftshift(RawFFT1) ;
MagFFT1=abs(ShiftedFFT1);
MaxFFT1=max(MagFFT1);
figure
plot(freqAxis(1:FFTsize),20*log10(MagFFT1))
xlabel('Freq [Hz]')
ylabel('dB relative')
title(title1)
axis([-MaxFreq MaxFreq -90 90])
hold on, grid on
if OneOrTwo==2
T = FFTsize ./ Fs;
k(1:FFTsize)=-FFTsize/2:FFTsize/2-1; %check for odd/even case****
RawFFT2=fft(TDsamples2,FFTsize);
ShiftedFFT2=fftshift(RawFFT2);
MagFFT2=abs(ShiftedFFT2);
MaxFFT2=max(MagFFT2);
plot(freqAxis(1:FFTsize),20*log10(MagFFT2),'r')
xlabel('Freq [Hz]')
ylabel('dB relative')
axis([-MaxFreq MaxFreq -90 90])
end
end
function [TDfirFFTClean, TDfirFFTNoisy] = myfft(TDsamples1,TDsamples2,FIRsamples,FFTsize,Fs,OneOrTwoFFT)
if FFTsize<length(TDsamples1) % must be at least as large as # of time-domain samples
disp('FFT length must be >= to number of time domain samples')
elseif FFTsize<length(TDsamples2);
disp('FFT length must be >= to number of time domain samples')
end
RawFFTFIR1=fft(FIRsamples,FFTsize);
RawFFT1=fft(TDsamples1,FFTsize);
firFFTCleanFD = RawFFT1.*RawFFTFIR1;
TDfirFFTClean = ifft(firFFTCleanFD,FFTsize,'symmetric');
if OneOrTwoFFT==2
RawFFT2=fft(TDsamples2,FFTsize);
firFFTNoisyFD = RawFFT2.*RawFFTFIR1;
TDfirFFTNoisy = ifft(firFFTNoisyFD,FFTsize,'symmetric');
end
function [RawFFT1, RawFFT2]= myLINfft(TDsamples1,TDsamples2,FFTsize,Fs,title1,OneOrTwo,MaxFreq)
if FFTsize<length(TDsamples1) % must be at least as large as # of time-domain samples
error('FFT length must be >= to number of time domain samples')
elseif FFTsize<length(TDsamples2)
error('FFT length must be >= to number of time domain samples')
end
T = FFTsize ./ Fs;
k(1:FFTsize)=-FFTsize/2:FFTsize/2-1; %check for odd/even case****
freqAxis=k(1:FFTsize) ./ T;
RawFFT1=fft(TDsamples1,FFTsize);
ShiftedFFT1=fftshift(RawFFT1) ;
MagFFT1=abs(ShiftedFFT1);
MaxFFT1=max(MagFFT1);
figure
plot(freqAxis(1:FFTsize),MagFFT1)
xlabel('Freq [Hz]'), ylabel('Relative amplitude')
title(title1)
axis([-MaxFreq MaxFreq 0 MaxFFT1+0.1*MaxFFT1])
hold on, grid on
if OneOrTwo==2
T = FFTsize ./ Fs;
k(1:FFTsize)=-FFTsize/2:FFTsize/2-1; %check for odd/even case****
RawFFT2=fft(TDsamples2,FFTsize);
ShiftedFFT2=fftshift(RawFFT2);
MagFFT2=abs(ShiftedFFT2);
MaxFFT2=max(MagFFT2);
plot(freqAxis(1:FFTsize),MagFFT2,'r')
xlabel('Freq [Hz]'), ylabel('Relative amplitude')
axis([-MaxFreq MaxFreq 0 MaxFFT1+0.1*MaxFFT1])
end
function aud = SSBdemod(modeDemod, fc)
%k = [55e3 65e3]; %sample range to use
k = [1 .2e6-1];
figure(1)
hT = subplot(3,1,1);
hD = subplot(3,1,2);
hF = subplot(3,1,3);
figure(2)
ht = subplot(2,1,1);
BW = 4e3; %one-sided bandwidth of audio to pass
taps = 100;
switch lower(modeDemod)
case 'am'
d = load('AMmod.mat');
case 'ssb'
d = load('SSBmod.mat', 'data');
otherwise
error('sorry, your mode is not yet defined')
end
t = (0:1/fs:1/fs*length(d.data(k(1):k(2)))-1/fs).';
data = 1/max(max(d.data(k(1):k(2),:))).*d.data(k(1):k(2),1); % %normalize Real data
N=2.^nextpow2(length(data)); %used for all FFTs
MyFFT(data,N,fs,fs/2,hT,'Raw Freq-domain RXdata');
plot(ht,data), title(ht,'Raw Time-domain RX data');
set(ht,'YLim',[-1 1])
switch lower(modeDemod)
case 'am'
% X = demod(data(:,1),10000,fs,'amdsb-tc');
data_demod = data.*(data>0); %ideal diode detector
data_demod = data_demod - mean(data_demod); %remove carrier DC offset
case 'ssb'
% first, shift incoming signal down to DC
data_demod = data.*2.*cos(2*pi*fc*t);
otherwise
error('sorry, your mode is not yet defined')
end
MyFFT(data_demod,N,fs,fs/2,hD,'Demod, no LPF');
b = fir1(taps,BW/fs);
data_filt = filter(b,1,data_demod);
MyFFT(data_filt,N,fs,fs/2,hF,'Demod and LPF');
aud = audioplayer(data_filt,fs,16,3); % sound card ID=3
play(aud)
end
function RawFFT = MyFFT(Tdata,FFTsize,Fs,MaxFreq,axHandle,titleText)
T = FFTsize ./ Fs;
k(1:FFTsize)=-FFTsize/2:FFTsize/2-1; %check for odd/even case****
freqAxis=k(1:FFTsize) ./ T;
RawFFT=fft(Tdata,FFTsize);
ShiftedFFT1=fftshift(RawFFT) ;
MagFFT1=abs(ShiftedFFT1);
%MaxFFT1=max(MagFFT1);
plot(axHandle,freqAxis(1:FFTsize),20*log10(MagFFT1))
xlabel(axHandle,'Freq [Hz]'), ylabel(axHandle,'dB relative')
title(axHandle,titleText)
set(axHandle,'XLim',[-MaxFreq MaxFreq],'YLim',[0 90],'XGrid','on','YGrid','on')
grid on
end
%Weaver method SSB generation
function WeaverSSBgen()
%% message
%Fs=4*44.1e3; %give some headroom for higher carrier frequencies
%BW=22.05e3;
Fs=50e3; %[Hz]
BW=4500; %[Hz]
MaxFreq=Fs/2;
%% voice mod
%t=0:1/Fs:9.355895;
%x=upsample(wavread('voice.wav').',4);
%fm=100; %[Hz]
fc=10000; %[Hz]
%% tone mod
%t=0:1/Fs:.025;
%x(1,:)=cos(2*pi*fm*t)+cos(4*pi*fm*t); %message m(t)
%sinc^2 mod
t=-.1:1/Fs:.1;
B=2e3; %[Hz]
x(1,:)=pi*B*sinc(2*pi*B*t).^2; %message m(t)
%% Filter setup
nFIR = 1024; % Pick a length long enough to give desired transition band.
WnFIRt = (BW/2)/(Fs/2); % NORMALIZED FREQ %set to be 1/2 BW for Weaver
WnFIRr = BW/(Fs/2); % NORMALIZED FREQ
TDSamplesT = fir1(nFIR-1,WnFIRt); %Hamming window
TDSamplesR = fir1(nFIR-1,WnFIRr); %Hamming window
N=2.^nextpow2(length(x)+nFIR); %used for all FFTs
figure
plot(t,x)
title('Time-domain message signal')
xlabel('Time [sec]')
ylabel('Amplitude [dimensionless]') %diag
%% Loop for USB/LSB cases
for flip=0:1
SSB=flip; %Enter 1 for LSB and 0 for USB;
%% message freq. shift oscillators
LOhalf0=2*cos(2*pi*BW/2*t-0); %half of the maximum BW
LOhalf90=2*cos(2*pi*BW/2*t-pi/2); %half of the maximum BW
%% SSB TX L.O.
LOtx0(1,:)=2*cos(2*pi*(fc+(-1)^SSB*BW/2)*t-0); %Transmit L.O.
LOtx90(1,:)=2*cos(2*pi*(fc+(-1)^SSB*BW/2)*t-pi/2); %Transmit L.O.
%% RX L.O.
LOrx(1,:)=2*cos(2*pi*(fc)*t+0);
%LOrx(2,:)=2*cos(pi*30e3*t+0); % add additional lines for off-freq receive
%% LPF for input file (to be sure it is appropriate for the up-conversion)
%xfilt=x; %No baseband filtering
xfilt = myfft(x,0,TDSamplesR,N,Fs,1);
xfilt = xfilt(nFIR/2:nFIR/2+length(x)-1);
title1=('Spectrum of Message Signal');
myLINfft(xfilt,0,N,Fs,title1,1,MaxFreq); %diag
%% upconvert signals
xupconv0=xfilt.*LOhalf0;
xupconv90=xfilt.*LOhalf90;
title1=('upconverted signal pre-LPF');
mydBfft(xupconv0,xupconv90,N,Fs,title1,2,MaxFreq); %diag
[firIFt(1,:), firIFt(2,:)] = myfft(xupconv0,xupconv90,TDSamplesT,N,Fs,2); %filter TX carrier signal
firIFtClip(1,:) = firIFt(1,nFIR/2:nFIR/2+length(x)-1);
firIFtClip(2,:) = firIFt(2,nFIR/2:nFIR/2+length(x)-1);
title1=('upconverted signal post-LPF');
mydBfft(firIFtClip(1,:),firIFtClip(2,:),N,Fs,title1,2,MaxFreq); %diag
%% upconvert signals to IF
xIF0=firIFtClip(1,1:length(x)).*LOtx0;
xIF90=firIFtClip(2,1:length(x)).*LOtx90;
firTDt=1/2*(xIF0+(-1)^SSB*xIF90);
title1=('TX signal output');
mydBfft(firTDt,0,N,Fs,title1,1,MaxFreq);
myLINfft(firTDt,0,N,Fs,title1,1,MaxFreq);
figure
plot(t,firTDt)
title('Time-domain SSB signal')
xlabel('Time [sec]')
ylabel('Amplitude [dimensionless]') %diag
TXenv(flip+1,:)=abs(hilbert(firTDt(1,:)));
figure
plot(t,TXenv(flip+1,:))
title('TX Envelope of SSB signal')
xlabel('Time [sec]')
ylabel('Amplitude [dimensionless]') %diag
%% Receive signals
for i=1:length(LOrx(:,1))
xrec(i,:)=firTDt(1,1:length(x)).*LOrx(i,:);
end
title1=('Spectrum of Demodulated Signal pre-LPF');
%mydBfft(xrec(1,:),0,N,Fs,title1,1,MaxFreq); %diag
firTDr = myfft(xrec(1,:),0,TDSamplesR,N,Fs,1); %for one RX freq
%for 2 RX freq
%[firTDr(1,:) firTDr(2,:)] = myfft(xrec(1,:),xrec(2,:),TDSamplesR,N,Fs,2);
firTDr = firTDr(1,nFIR/2:nFIR/2+length(x)-1);
title1=('Spectrum of Demodulated Signal post-LPF');
mydBfft(firTDr(1,:),0,N,Fs,title1,1,MaxFreq); %diag
%% TD demod plots
figure
plot(t,firTDr(1,:))
title('Time-domain RX demod signal'),xlabel('Time [sec]'),ylabel('Amplitude [dimensionless]') %diag
%for 2 rx freq
%subplot(2,1,2),plot(t,firTDr(2,nFIR/2:end-nFIR/2))
%axis([0,t(end),-1,1])
%% envelope comparison
%RXenv=firTDr(1,:).*(firTDr(1,:)>0); %half-wave rectifier
RXenv(flip+1,:)=abs(hilbert(firTDr(1,:)));
figure
plot(t,RXenv(flip+1,:))
title('RX Envelope of SSB signal')
xlabel('Time [sec]')
ylabel('Amplitude [dimensionless]') %diag
end
figure
plot(t,RXenv(1,:)-RXenv(2,:))
title('Comparison of RX LSB/USB envelopes (subtraction)')
xlabel('Time [sec]')
ylabel('Amplitude [dimensionless]') %diag
figure
plot(t,TXenv(1,:)-TXenv(2,:))
title('Comparison of TX LSB/USB envelopes (subtraction)')
xlabel('Time [sec]')
ylabel('Amplitude [dimensionless]') %diag
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment