我是靠谱客的博主 淡淡月饼,最近开发中收集的这篇文章主要介绍matlab simulink ts,Matlab Simulink 基础到高级 2020-03-29~30,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

基础

1. Simulink Onramp三小时交互式课程

learning.simulink.launchOnramp('simulink')

界面操作

空格,将仿真图放在合适位置;空格+鼠标拖拽移动;滚轮缩放。

Enter打开模块,Alt+Enter输入模块主要参数。

更多参考:Simulink 建模的键盘和鼠标操作

模块

Math Function提供了指数、自然对数、以 10 为底的幂、常用(以 10 为底)对数、复数模量、2 次幂、幂、复共轭、倒数、平方和的平方根、除后的余数、除后的模数、转置、复共轭转置等多种运算。

Compare to Zero and Compare to Constant allow for convenient comparisons to a fixed, known value. Other blocks, such as the Relational Operator, allow for a dynamic comparison between two inputs.

Switch 模块根据第二个输入的值,传递第一个输入或第三个输入信号。第一个和第三个输入是数据输入。第二个输入是控制输入。可以使用 Criteria for passing first input 和 Threshold 参数指定模块传递第一个输入的条件。

Try creating other algorithms that combine the Switch with math and logic blocks.

For example, how would you output any negative values of the sine wave as zero (a half-wave rectifier)? What about outputting any negative values as positive (a full-wave rectifier)?

a half-wave rectifier

if (Sine Wave > 0)

output value of Sine Wave

else

output 0

end

a full-wave rectifier

if (Sine Wave > 0)

output value of Sine Wave

else

output -1*Sine Wave

end

参数变量

Base Workspace是创建Matlab Workspace变量,可以在各个模型中使用;而Model Workspace中变量只能在本模型中使用。

Simulink is built on top of MATLAB. You can create variables using MATLAB scripts or use MATLAB to pre-process data to be used in Simulink. Using variables for block parameters also allows you to share related values across blocks.

Try typing variable MATLAB expressions, such as r*2 into various parameter fields to see what Simulink accepts.

7.2 Matlab Function

Matlab Function 在Simulink -> User defined functions中。

Try adding a function output to return the wave velocity, v=G2gΔH. To see the new port in Simulink, open the Build Model menu in the MATLAB toolstrip and choose Update Ports (Ctrl+Shift+A)(直接保存Matlab Function 文件也可以更新端口)。

function [power,v] = fcn(deltaH)

Cp = 0.35; % Power coefficient

rho = 1000; % Density of water, kg/m^3

A = pi*10^2; % Area of turbine blade

g = 9.81; % Acceleration of gravity, m/s^2

power = 0.5*Cp*rho*A*(2*g*abs(deltaH))^(3/2)

v= sqrt(2*g*abs(deltaH))

动态响应

连续系统是采样时间Ts非常小近似为0,离散系统是自己给定采样时间Ts。

离散系统

1/z单位延迟是对离散信号延迟一个采样时间。

Unit Delay

The Unit Delay block has its own Sample time parameter. By default, this is set to -1, meaning that it inherits the sample time from elsewhere in the model—in this case, from the Sine Wave. However, you can also specify an independent rate for the Unit Delay; for example, if you need to downsample your signal.

Models with a mix of sample times are called multirate models. You can visualize sample times by using the Information Overlays drop down in the Debug tab.

Information Overlays

Use this dialog to toggle the display of sample times as Colors, Text, or both. Notice that enabling either of these displays will automatically open the Timing Legend.

Summary - Modeling Difference Equations

To model difference equations, use the following procedure. This applies to both single equations as well as systems of equations.

As an example, consider the set of equations:

x[k]−x[k−1]=u[k]−u[k−1]

u[k]=sin[k]

Arrange the equations so the most recent state is on the left hand side of the equation, and the remaining terms are on the right.

Determine the number of Unit Delay blocks required. In this case, there are two delays in the equations, so two Unit Delay blocks are necessary.

x[k] -> x[k-1]

u[k] -> u[k-1]

Add the Unit Delay blocks and label their signals.

左右拖拽,双击线标注,输入信号为x_k输出信号为x_kminus1

Construct the right side of the equation(s).

Connect the remaining signal(s), as necessary, to finish the equality.

Finally, set all sample times and initial conditions.

连续系统

integrator 符号1/s输入为first derivative(一阶导数)

,在信号线上记为x_dot,积分输出为x。

Simulink allows you to model different kinds of systems easily using the same methods you just learned. Check out the documentation examples for more.

For instance, you can model systems with many degrees-of-freedom, like this half-car suspension model)), or non-linear systems, such as this friction model with hard stops)).

Summary - Modeling Continuous Equations

Modeling continuous systems (differential equations) follows a process similar to the process for modeling discrete systems.

As an example, consider the differential equation:

Arrange the equations so the highest order derivatives are isolated on the left hand side of the equation, and the remaining terms are on the right.

Determine the number of Integrator blocks required. In this case, there are two integrations in the equations, so two Integrator blocks are necessary.

Add the Integrator blocks and label their signals.

V_dotdot -> 1/s -> V_dot -> 1/s -> V

Construct the right side of the equation(s).

Connect the remaining signal(s), as necessary, to finish the equality.

Finally, set the initial conditions. 连续系统省去了Ts采样时间设置。

solver settings, see Choose a Solver in the documentation.

You can learn more about solvers from the Compare Solvers)) documentation page. Information about solver time steps is on the fixed-step size))and max step size)) pages.

离散PID

Congratulations, you've modeled a discrete, proportional-integral controller in Simulink. Try changing the values of Kp,Ki, and Ts and see how they affect the controller output.

Simulink also ships with prebuilt controller blocks. You can read about PID controllers and discrete PID controllers);) in the documentation.

Kp加快调节速度,Ki过大系统不稳定,超调很大;过小则始终存在稳态误差;Ts过大则调节时间边长。

MathWorks Training

My Courses - Print or share a progress certificate for Simulink Onramp and explore other courses available to you.

Note: Submitting the survey at the end of the course is required for 100% completion.

Instructor-led courses - Take an in-person class from an experienced Simulink instructor.

Simulink Resources

Simulink Getting Started Guide - A set of tutorials that continue into more advanced topics such as model hierarchy and design principles.

MathWorks examples - Documentation page containing example models, grouped by application.

Additional Capabilities

Stateflow Product Page - Stateflow is an environment that can be used within Simulink to model logic systems and state machines.

Model-Based Design - Learn about the tools available to implement model-based design in Simulink.

2. 交互式模型编辑:

To workspace模块可以保存数据到Matlab Workspace;

可以直接拖动一个箭头到子模块,为子模块添加一个输出/输入端口;

3. 编程式模型编辑:

高级

细节

最后

以上就是淡淡月饼为你收集整理的matlab simulink ts,Matlab Simulink 基础到高级 2020-03-29~30的全部内容,希望文章能够帮你解决matlab simulink ts,Matlab Simulink 基础到高级 2020-03-29~30所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(51)

评论列表共有 0 条评论

立即
投稿
返回
顶部