-
大小: 15KB文件类型: .c金币: 1下载: 0 次发布日期: 2021-06-03
- 语言: Matlab
- 标签: FAS v8 S_function
资源简介
FAST v8 版本S_function 的资源,可以在Simulink中利用NREL的FAST
code 进行风力机的仿真
代码片段和文件信息
/*
* TEMPLATE File: sfuntmpl_gate_fortran.c
* TEMPLATE Copyright 1990-2013 The MathWorks Inc.
*
* Modified by B. Jonkman National Renewable Energy Laboratory
* for use with FAST v8
* 20-Jan-2015
*/
/*
* You must specify the S_FUNCTION_NAME as the name of your S-function
* (i.e. replace sfungate with the name of your S-function which has
* to match the name of the final mex file e.g. if the S_FUNCTION_NAME
* is my_sfuntmpl_gate_fortran the mex filename will have to be
* my_sfuntmpl_gate_fortran.mexXXX where XXX is the 3 letter
* mex extension code for your platform).
*/
#define S_FUNCTION_LEVEL 2
#define S_FUNCTION_NAME FAST_SFunc
/*
* Need to include simstruc.h for the definition of the SimStruct and
* its associated macro definitions.
*/
#include “simstruc.h“
#include “mex.h“ // for mexPutVariable
#include “matrix.h“ // for mxCreateDoubleScalar
#include “FAST_Library.h“
#define PARAM_FILENAME 0
#define PARAM_TMAX 1
#define PARAM_ADDINPUTS 2
#define NUM_PARAM 3
// two DWork arrays:
#define WORKARY_OUTPUT 0
#define WORKARY_INPUT 1
static double dt = 0;
static double TMax = 0;
static int NumInputs = NumFixedInputs;
static int NumAddInputs = 0; // number of additional inputs
static int NumOutputs = 1;
static int ErrStat = 0;
static char ErrMsg[INTERFACE_STRING_LENGTH]; // make sure this is the same size as IntfStrLen in FAST_Library.f90
static char InputFileName[INTERFACE_STRING_LENGTH]; // make sure this is the same size as IntfStrLen in FAST_Library.f90
static int n_t_global = -2; // counter to determine which fixed-step simulation time we are at currently (start at -2 for initialization)
// function definitions
static int checkError(SimStruct *S);
static void mdlTerminate(SimStruct *S); // defined here so I can call it from checkError
static void getInputs(SimStruct *S double *InputAry);
static void setOutputs(SimStruct *S double *OutputAry);
/* Error handling
* --------------
*
* You should use the following technique to report errors encountered within
* an S-function:
*
* ssSetErrorStatus(S“Error encountered due to ...“);
* return;
*
* Note that the 2nd argument to ssSetErrorStatus must be persistent memory.
* It cannot be a local variable.
*/
static int
checkError(SimStruct *S){
if (ErrStat >= AbortErrLev){
ssPrintf(“\n“);
ssSetErrorStatus(S ErrMsg);
mdlTerminate(S); // terminate on error (in case Simulink doesn‘t do so itself)
return 1;
}
else if (ErrStat >= ErrID_Warn){
ssPrintf(“\n“);
ssWarning(S ErrMsg);
}
else if (ErrStat != ErrID_None){
ssPrintf(“\n%s\n“ ErrMsg);
}
return 0;
}
static void
getInputs(SimStruct *S double *InputAry){
int k;
InputRealPtrsType uPtrs = ssGetInputPortRealSignalPtrs(S 0);
for (k = 0; k < ssGetDWorkWidth(S WORKARY_INPUT); k++) {
InputAry[k] = (double)(
- 上一篇:图像处理中经典细化算法集合matlab
- 下一篇:EKF_matlab
相关资源
- Kalman滤波S-Function程序
-
用GUI实时更改simuli
nk仿真参数 -
基于simuli
nk的s-function的PWM生成.rar - nl-means算法
- matlab FastICA工具箱111010
- Fast ICA matlab源代码
- fastica工具箱
- fast ICA的Matlab代码
- matlab 实现fastica源代码
- 使用S-Function函数实现离散PID控制器,
- fast ica matlab程序
- 用于解决复杂网络社区划分的FastNew
- fasleh2
- S-Function编写指导及.zip
- FastIca盲源分离算法(Matlab编写)
- 20190903chromium v8 depot_tools+源码
- fastica的matlab实现
- matlab fastica工具箱
- 超强FastICA算法matlab程序+gui操作
- matlab S-function 编写的离散状态空间表
- ICA算法和FASTICA算法
- rcnnPfast-rcnnPfaster-rcnn 物体分割
- fastlaplacemorian 压缩感知的几种算法算
- ica-matlab 脑电信号 分析 fast ica去噪
-
FRSR 实现文献‘Fast and robust multif
r - Fast-a-Robust-Super-Resolution(BTV)
- fastHOG3D--full-version 一个完整版
- [HHT]-fast-EMDEEMDCEEMD-with-ref 本压缩文件
- Fast-Kurtogram 快速谱峭度工具箱
- Fast-Kurtogram 轴承故障谱峭度分析
评论
共有 条评论