关于Error reported by S-function ‘sysgen‘ in ‘untitled/Gateway In‘的解决办法

在使用System Generator软件时,运行后出现以下错误:

Error reported by S-function 'sysgen' in 'Gateways/Gateway In' [matlab:das_dv_hyperlink('DAS','mdl','Gateways/Gateway In')]: An internal error occurred in the Xilinx Blockset Library.

Please report this error to Xilinx (http://support.xilinx.com), in as much detail as possible. You may also find immediate help in the Answers Database and other online resources at http://support.xilinx.com.

Since it is possible that this internal error resulted from an unhandled usage error in your design, we advise you to carefully check the usage of the block reporting the internal error. If errors persist, we recommend that you restart MATLAB.

解决办法:

不要通过matlab软件打开sysgen模型。

先关闭matlab以及sysgen模型,再打开System Generator软件,打开模型即可。

S-function是Simulink中的一个组件,可以使用C/C++或Matlab代码来自定义Simulink模块的行为。DSB调制可以通过编写S-function来实现。 下面是一个简单的S-function示例,用于实现DSB调制: ```c #define S_FUNCTION_NAME dsb_mod #define S_FUNCTION_LEVEL 2 #include "simstruc.h" static void mdlInitializeSizes(SimStruct *S) { ssSetNumSFcnParams(S, 0); if (ssGetNumSFcnParams(S) != ssGetSFcnParamsCount(S)) { return; /* Parameter mismatch will be reported by Simulink */ } ssSetNumContStates(S, 0); ssSetNumDiscStates(S, 0); if (!ssSetNumInputPorts(S, 1)) return; ssSetInputPortWidth(S, 0, 1); ssSetInputPortDataType(S, 0, SS_DOUBLE); if (!ssSetNumOutputPorts(S, 1)) return; ssSetOutputPortWidth(S, 0, 1); ssSetOutputPortDataType(S, 0, SS_DOUBLE); ssSetNumSampleTimes(S, 1); ssSetOptions(S, 0); } static void mdlInitializeSampleTimes(SimStruct *S) { ssSetSampleTime(S, 0, INHERITED_SAMPLE_TIME); ssSetOffsetTime(S, 0, 0.0); } static void mdlOutputs(SimStruct *S, int_T tid) { real_T *y = ssGetOutputPortRealSignal(S,0); real_T *x = ssGetInputPortRealSignal(S,0); y[0] = 0.5 * x[0] * cos(2 * 3.1415926 * 1000 * ssGetT(S)); } static void mdlTerminate(SimStruct *S) { } #ifdef MATLAB_MEX_FILE #include "simulink.c" #else #include "cg_sfun.h" #endif ``` 在S-function中,我们定义了一个模块的输入和输出端口,以及模块的行为。在这个例子中,我们使用输入信号进行DSB调制,输出调制后的信号。具体实现方式是将输入信号乘以1000Hz的正弦波,然后再乘以0.5。 使用S-function实现DSB调制后,可以将其作为Simulink模型中的一个模块使用。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值