simulink编译警告的解决办法

下面是使用simulink过程中出现的警告及解决方法,特此记录。

1,警告: You have required continuous-time simulation of a system containing switches or nonlinear elements. 
The ode23tb variable-step stiff solver with relative tolerance set to 1e-4 generally gives best accuracy and simulation performance. 
For some highly nonlinear models it may be necessary to set the "Solver reset method" parameter to "Robust". 
See "Improving Simulation Performance" chapter in Simscape Power Systems documentation for additional information on how to select an appropriate integration method.
To ignore Simscape Power Systems (Specialized Technology) warnings, select "Disable Simscape Power Systems ST warnings" in the Powergui Preferences tab.

解决办法:

修改powergui属性,由原来的continue改为

然后,编译通过。

 

2,
Output port 1 of 'industrial_frequency_charger/Mosfet1' is not connected.
Component:Simulink | Category:Blockwarning
Output port 1 of 'industrial_frequency_charger/Mosfet2' is not connected.
Component:Simulink | Category:Blockwarning
Output port 1 of 'industrial_frequency_charger/Mosfet3' is not connected.
Component:Simulink | Category:Blockwarning
Output port 1 of 'industrial_frequency_charger/Mosfet4' is not connected.

解决办法:

Mos的m脚悬空了,用Terminator接上就好了。

3,Data type mismatch.

Input port 1 of 'mppt_charger/S-Function2' expects a signal of data type 'double'. However, it is driven by a signal of data type 'boolean'.

解决办法:在s函数输入前增加数据类型转换模块即可。将输出类型设为double

4,

 

这是在s函数有两个输入端口的情况下出现的问题,运行就跳出这个错误。后来通过注释S函数代码,发现只要不访问s函数的输入,就不会有这个问题。所以,确定了是s函数输入的问题。后来,改为一个输入,也没有问题。最后,查看mdlInitializeSizes,发现有些人使用了ssSetInputPortRequiredContiguous,也有人没有使用,这个函数的含义也是模模糊糊,没人说得清。于是,注释了这个函数,发现可以工作了,具体为啥也不清楚,就先这样用吧。

 

5,编译s函数的c文件时,找不到编译器

解决办法:

首先,确认是否按照相应编译器。

其次,确认是否添加了编译器的路径。

可通过setenv('MW_MINGW64_LOC','C:\TDM-GCC-64'),具体路径根据你的实际安装路径来填写。每次开启matlab都要添加一次。

 

6,PV array运行出错

An error occurred while running the simulation and the simulation was terminated
Caused by:
Simulink cannot solve the algebraic loop containing 'PV_mppt_charger/PV Array/Diode Rsh/Product5' at time 2.0E-6 using the TrustRegion-based algorithm due to one of the following reasons: the model is ill-defined i.e., the system equations do not have a solution; or the nonlinear equation solver failed to converge due to numerical issues.
 To rule out solver convergence as the cause of this error, either
     a) switch to LineSearch-based algorithm using
         set_param('PV_mppt_charger','AlgebraicLoopSolver','LineSearch')
     b) reducing the VariableStepDiscrete solver RelTol parameter so that the solver takes smaller time steps.
 If the error persists in spite of the above changes, then the model is likely ill-defined and requires modification.

根据提示提供的方法修改:

a),在command window输出set_param('PV_mppt_charger','AlgebraicLoopSolver','LineSearch') ,然后回车

b),将步长由原来的1e-7改为1e-9

上述方法中任一种都可运行。

 

7,使用trigger模块编译报错

The trigger input port of triggered subsystem or Model block 'PV_mppt_charger/Triggered Subsystem1' is involved in a loop. This causes the  trigger signal at time t to be dependent on the output of the triggered subsystem or Model block at time t, resulting in an ambiguous execution order. You can use a Memory to break the loop.

解决办法:

在triggered subsystem的输出增加一个Memory模块

8,运行报错误“未定义与‘struct'类型的输入参数相对应的函数’getNumInputs”

原因:模型建在了中文目录下,换为英文目录错误就消失了,切记不要有中文字符,所有开发软件都一样,尽量不要用英文字符,避免不必要的麻烦。

 

9,自定义的s函数运行时间快了一倍。

原因:在同一个模型中,两个s函数模块都调用同一个s函数文件,导致相互影响,要注意这个问题。

 

 

  • 14
    点赞
  • 54
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值