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
    评论
Simulink代数环解决方法是一种基于Simulink工具的动力学问题求解方法。在动力学问题中,我们通常关注系统的运动和力学行为。Simulink作为一种模拟和建模工具,能够帮助我们分析和解决这些动力学问题。 在Simulink中,我们可以通过建立系统模型来描述动力学系统。模型中的各个组件可以表示系统中的各个部分,例如质点、弹簧、阻尼器等等。通过将这些组件连接起来,并设定参数和初始条件,我们可以得到整个系统的运动方程。 Simulink代数环是Simulink中的一个功能模块,通过使用代数环,我们可以将非线性的微分方程转化为一组代数方程。这样,我们可以采用代数求解器来求解这组方程,得到系统的解。 使用Simulink代数环解决动力学问题的步骤一般包括:建立系统模型、设定参数和初始条件、选择合适的求解器、运行仿真。在仿真过程中,Simulink会对系统进行数值求解,并可以绘制出系统各个变量随时间的变化情况。 Simulink代数环解决方法的优势在于可以方便地建立复杂的系统模型,并进行快速的仿真。通过Simulink工具箱中丰富的组件库,我们可以模拟各种各样的动力学系统,从简单的单自由度系统到复杂的多自由度系统。同时,Simulink还提供了多种求解器,可以根据系统的特点和需求选择合适的求解算法,提高求解效率和准确性。 综上所述,Simulink代数环是一种实用的工具,可用于解决动力学问题。通过使用Simulink进行系统的建模、仿真和分析,我们可以更好地理解系统的行为,并找到满足特定需求的解决方案。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值