/* File : sfun_fcncall.c
* Abstract:
*
* Example of an S-function which is configured to execute "function-call"
* subsystems on the 1st and 2nd elements of the 1st output port. Note that
* function-calls can be issued from the 1st output port only.
*
* For more details about S-functions, see
*
* Copyright 1990-2013 The MathWorks, Inc.
*/
#define S_FUNCTION_NAME sfun_fcncall
#define S_FUNCTION_LEVEL 2
#include "simstruc.h"
static void mdlInitializeSizes(SimStruct *S)
{
ssSetNumSFcnParams(S, 0); /* Number of expected parameters */
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);
ssSetInputPortDirectFeedThrough(S, 0, 1);
if (!ssSetNumOutputPorts(S,1)) return;
ssSetOutputPortWidth(S, 0, 2);
/* All output elements are function-call, so we can set the data type of the
* entire port to be function-call. */
ssSetOutputPortDataType(S, 0, SS_FCN_CALL);
/* specify the sim state compliance to be same as a built-in block */
ssSetSimStateCompliance(S, USE_DEFAULT_SIM_STATE);
ssSetOptions(S, SS_OPTION_EXCEPTION_FREE_CODE);
}
static void mdlInitializeSampleTimes(SimStruct *S)
{
ssSetSampleTime(S, 0, 0.1);
ssSetOffsetTime(S, 0, 0.0);
ssSetCallSystemOutput(S,0); /* call on first element */
ssSetCallSystemOutput(S,1); /* call on second element */
ssSetModelReferenceSampleTimeDefaultInheritance(S);
}
static void mdlOutputs(SimStruct *S, int_T tid)
{
real_T *x = ssGetRealDiscStates(S);
InputRealPtrsType uPtrs = ssGetInputPortRealSignalPtrs(S,0);
real_T *y = ssGetOutputPortRealSignal(S,1);
/*
* ssCallSystemWithTid is used to execute a function-call subsystem. The
* 2nd argument is the element of the 1st output port index which
* connected to the function-call subsystem. Function-call subsystems
* can be driven by the first output port of s-function blocks.
*/
UNUSED_ARG(tid); /* not used in single tasking mode */
if (((int)*uPtrs[0]) % 2 == 1) {
if (!ssCallSystemWithTid(S,0,tid)) {
/* Error occurred which will be reported by Simulink */
return;
}
} else {
if (!ssCallSystemWithTid(S,1,tid)) {
/* Error occurred which will be reported by Simulink */
return;
}
}
}
static void mdlTerminate(SimStruct *S)
{
}
#ifdef MATLAB_MEX_FILE /* Is this file being compiled as a MEX-file? */
#include "simulink.c" /* MEX-file interface mechanism */
#else
#include "cg_sfun.h" /* Code generation registration function */
#endif
没有合适的资源?快使用搜索试试~ 我知道了~
simulink仿真 - simulink
共66个文件
slx:50个
m:12个
slxc:1个
需积分: 5 0 下载量 196 浏览量
2024-11-08
23:22:47
上传
评论
收藏 814KB RAR 举报
温馨提示
simulink仿真 - simulink simulink模块、流控制、保存模型为图片、回调函数、信号、子系统、模型的仿真、界面介绍
资源推荐
资源详情
资源评论
收起资源包目录
simulink仿真.rar (66个子文件)
simulink仿真
第二章 Simulink模块
chap02_03_62_mdl.slx 16KB
chap02_cyclesignal.slx 23KB
chap02_03_12_mdl.slx 13KB
chap02_03_49_mdl.slx 15KB
chap02_92.slx 22KB
chap02_02_57_mdl.slx 13KB
chap02_100.slx 23KB
chap02_02_47_mdl.slx 14KB
chap02_03_43_mdl.slx 15KB
chap02_03_10.slx 22KB
chap02_02_112_mdl.slx 22KB
chap02_128.slx 24KB
chap02_33.slx 22KB
chap02_03_46_mdl.slx 14KB
chap02_step.slx 21KB
chap02_03_36_mdl.slx 14KB
chap02_61.slx 14KB
chap02_63.slx 16KB
chap02_113.slxc 5KB
chap02_30.slx 21KB
chap02_02_112_mdl.slx.r2013b 12KB
chap02_38.slx 23KB
chap02_111.slx 22KB
chap02_02_77_mdl.slx 26KB
chap02_02_88_mdl.slx 14KB
chap02_113.slx 26KB
chap02_75.slx 13KB
chap02_47.slx 23KB
chap02_02_89_mdl.slx 14KB
第四章 Simulink子系统
chap04_02_18_mdl.slx 15KB
sfun_fcncall.c 3KB
chap04_01_03_mdl.slx 14KB
chap04_02_33_mdl.slx 13KB
chap04_01_02_mdl.slx 14KB
第七章 Simulink的回调函数
listblock_callback.m 823B
chap07_07_02_mdl.slx 13KB
open_scope.m 132B
chap07_07_07_mdl.slx 14KB
connect_msg.m 195B
chap07_07_03_mdl.slx 11KB
第九章 Simuink 的流控制
flow_control_for.slx 19KB
Saint.m 204B
flow_control_if.slx 15KB
BasicColors.m 116B
flow_control_switch.slx 14KB
flow_control_while.slx 15KB
第六章 Simulink保存模型为图片
sldemo_counters.slx 17KB
chap06_03_03_script.m 180B
第五章 Simulink模型的仿真
chap05_01_15.slx 14KB
chap05_03_18.slx 13KB
第三章 Simulink 信号
chap03_04_09_mdl.slx 12KB
chap03_varsize_line_mdl.slx 14KB
第一章 Simulink界面介绍
chap01_02.m 115B
chap01_01.m 93B
第八章 M语言对Simulink模型的自动化操作及配置
chap08_01_04_script.m 790B
m_control_02.slx 12KB
m_control_01.slx 11KB
section_model.fig 5KB
m_control_06.slx 9KB
chap08_02_01_script.m 220B
m_control_07.slx 16KB
section_model.m 10KB
m_control_04.slx 13KB
m_control_05.slx 18KB
chap08_01_05_script.m 802B
m_control_03.slx 12KB
共 66 条
- 1
资源评论
电科_银尘
- 粉丝: 1w+
- 资源: 103
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- map_mode_escape_1.28.13.12700.pak
- androidx.multidex.MultiDexApplication.apk.1
- 丑子金装美化32(1).zip
- 基于Visual Basic .Net及Python技术的学校需求解决方案设计源码
- 基于Java语言的Web开发学习Demo设计源码
- 基于Java的医院排队叫号系统界面原型设计源码
- 基于Java语言的Himalaya仿喜马拉雅设计源码
- 基于PHP+HTML+CSS+JavaScript的智能电车管家设计源码
- 基于Emscripten编译的纯H5直播流播放器jessibuca设计源码
- 基于react-native的Android隐私合规配置与代码集成设计源码
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功