求助,.c文件编译为.dll文件出错
#define S_FUNCTION_NAMEs_friction_woodchen#define S_FUNCTION_LEVEL 2
#include "simstruc.h"
static void mdlInitializeSizes(SimStruct *S)
{
ssSetNumSFcnParams(S, 0);
if (ssGetNumSFcnParams(S) != ssGetSFcnParamsCount(S)) {
return;
}
ssSetNumContStates(S, 0);
ssSetNumDiscStates(S, 0);
if (!ssSetNumInputPorts(S, 1)) return;
ssSetInputPortWidth(S, 0, 1);
ssSetInputPortRequiredContiguous(S, 0, 0);
ssSetInputPortDirectFeedThrough(S, 0, 1);
if (!ssSetNumOutputPorts(S, 1)) return;
ssSetOutputPortWidth(S, 0, 1);
ssSetNumSampleTimes(S, 1);
ssSetNumRWork(S, 0);
ssSetNumIWork(S, 0);
ssSetNumPWork(S, 0);
ssSetNumModes(S, 0);
ssSetNumNonsampledZCs(S, 0);
//ssSetOptions(S, 0);
}
static void mdlInitializeSampleTimes(SimStruct *S)
{
ssSetSampleTime(S, 0, INHERITED_SAMPLE_TIME);
ssSetOffsetTime(S, 0, 0.0);
ssSetModelReferenceSampleTimeDefaultInheritance(S);
}
#define MDL_INITIALIZE_CONDITIONS
#if defined(MDL_INITIALIZE_CONDITIONS)
static void mdlInitializeConditions(SimStruct *S)
{
}
#endif
#define MDL_START
#if defined(MDL_START)
static void mdlStart(SimStruct *S)
{
}
#endif
static void mdlOutputs(SimStruct *S, int_T tid)
{
real_T u =ssGetInputPortSignal(S,0);
real_T f = ssGetOutputPortSignal(S,0);
//y = u;
int_T sgn;
real_T g,z;
real_T Q0=1e5;
real_T Q1=sqrt(1e5);
if u>0
sgn=1;
elseif u<0
sgn=-1;
else
sgn=0;
g=(1+0.5*exp(-1*(u/0.2)^2))/Q0;
z=g*sgn;
f=Q0*z+Q1*(u-abs(u)*z/g);
}
#define MDL_UPDATE
#if defined(MDL_UPDATE)
static void mdlUpdate(SimStruct *S, int_T tid)
{
}
#endif
#define MDL_DERIVATIVES
#if defined(MDL_DERIVATIVES)
static void mdlDerivatives(SimStruct *S)
{
}
#endif
static void mdlTerminate(SimStruct *S)
{
}
#ifdefMATLAB_MEX_FILE
#include "simulink.c"
#else
#include "cg_sfun.h"
#endif 利用mex命令编译以后出现如下错误:
‘initilizing’: incompatible types
'function': convertion from 'double' to 'int', possible loss of data
请大家帮我看看那里出现问题了,我已经查了2天了,实在查不出来。 % dz |v|
% ---- = v ------ * z ...............(1)
% dt g(v)
% dz
% F = Q0*z + Q1* ---- +Q2*v ...............(2)
% dt
% 2
% -(v/vs)
% Q0*g(v) = Fc + ( Fs - Fc )*exp ...............(3)
通过3个公式算F的值 数据类型不同的问题。确定它们的数据类型相同
页:
[1]