Simulink 配置集(一)什么是配置集

说明:本文基于 MATLAB 2016a

 

配置集(Configuration Set)就是模型的参数配置集合,simulink 建模十分灵活强大,所以需要众多的参数设置,常用有几个方面(MathWorks 自称为 componets,即“组件”):

 

• Solver // 解算器

• Data Import/Export // 数据输入输出

• Optimization // 优化

• Diagnostics // 诊断

• Hardware Implementation // 硬件实现

• Model Referencing // 模型参考

• Simulation Target // 模拟目标

 

ps. 不同的 MathWorks 产品,配置集中会显示不同的默认组件

 

ps. 上述组件的中文翻译都是直译,一般使用时直呼英文名称,翻译的不准仅作参考

 

示例

 

任意模型界面,通过 Ctrl + H 可以打开 Model Explorer,如下图,包含三个模型,demo_model1~3,所有模型的 Configuration 处于激活状态

选中某个 Configuration,可以在 Contents 中看到内容(只显示 Default 内容,即上述常用组件),在最右 Dialog 中更改配置集名称、添加备注等

可以右键单击某个 Configuration,使其处于激活状态

一个模型可以有多个 Configuration,但只能有一个处于激活状态,通过激活不同的配置集,快速对模型参数进行配置

选中 Contents 中的某个组件,最右 Dialog 中显示其具体内容,和在模型中 Ctrl + E 显示的内容一致

 

导出配置集

 

可以在 Model Explorer 中的模型右击,Configuration → Export Active Configuration 导出配置集:


 

• 导出的配置集可以是 .m 文件或 .mat 文件

• 前者包含创建配置集的函数

• 后者包含配置集对象

• 如果要在模型中导入配置集,必须是配置集对象,即 .mat 文件

以上操作也可以通过 Matlab 代码实现,在 Command Window 中:

cs = getConfigSet('demo_model1','Configuration1'); // 将模型 demo_model1 中的 Configuration1 保存成 ConfigSet 对象,名为 cs
save('Config_model1_1.mat','cs'); // 这里也可以保存成 .m 文件

 

配置集 .m 文件

 

function cs = Config_model1()
%---------------------------------------------------------------------------
%  MATLAB function for configuration set generated on 15-Jul-2018 17:24:58
%  MATLAB version: 9.0.0.341360 (R2016a)
%---------------------------------------------------------------------------

cs = Simulink.ConfigSet;

% Original configuration set version: 1.16.2
if cs.versionCompare('1.16.2') < 0
    error('Simulink:MFileVersionViolation', 'The version of the target configuration set is older than the original configuration set.');
end

% Original environment character encoding: GBK
if ~strcmpi(get_param(0, 'CharacterEncoding'), 'GBK')
    warning('Simulink:EncodingUnMatched', 'The target character encoding (%s) is different from the original (%s).',  get_param(0, 'CharacterEncoding'), 'GBK');
end

% Original configuration set target is ert.tlc
cs.switchTarget('ert.tlc','');

% Do not change the order of the following commands. There are dependencies between the parameters.
cs.set_param('Name', 'Configuration1'); % Name
cs.set_param('Description', ''); % Description

% Solver
cs.set_param('StartTime', '0.0');   % Start time
cs.set_param('StopTime', '11');   % Stop time
cs.set_param('SolverType', 'Fixed-step');   % Type
cs.set_param('EnableConcurrentExecution', 'off');   % Show concurrent execution options
cs.set_param('SampleTimeConstraint', 'Unconstrained');   % Periodic sample time constraint
cs.set_param('Solver', 'FixedStepDiscrete');   % Solver
cs.set_param('FixedStep', '0.01');   % Fixed-step size (fundamental sample time)
cs.set_param('SolverMode', 'Auto');   % Tasking mode for periodic sample times
cs.set_param('AutoInsertRateTranBlk', 'off');   % Automatically handle rate transition for data transfer
cs.set_param('PositivePriorityOrder', 'off');   % Higher priority value indicates higher task priority

% Data Import/Export
cs.set_param('LoadExternalInput', 'off');   % Load external input
cs.set_param('LoadInitialState', 'off');   % Load initial state

上述为部分配置集的 .m 代码,可以看出,主要是通过代码对参数进行设置,好处:

1. 众多参数中,常用配置不多,其他都保持默认,默认的可以删除,只保留需变更的配置项即可

2. 直接将其他模型的 .m 文件价拷贝过来即可

  • 5
    点赞
  • 36
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
在基于Simulink使用射频模块天线块对天线阵列的射频系统进行建模时,我们可以利用Matlab中的Simulink工具箱实现。首先,我们需要了解天线阵列的结构和性能需求,包括天线的类型、数量和排列方式等。接下来,我们可以按照以下步骤进行建模: 1. 打开Matlab软件,创建一个新的Simulink模型。 2. 在Simulink模型中,找到射频模块库。这个模块库包含了天线、天线数据源、天线接收器等各种射频模块。 3. 在模型中添加一个天线阵列模块,该模块代表了整个天线阵列的结构。可以设置天线的数量、类型和排列方式等参数。 4. 在天线阵列模块中添加射频信号源,该信号源可以代表射频信号的发射器。设置信号源的参数,如载波频率、发射功率和调制方式等。 5. 连接信号源和天线阵列模块,建立起信号传输的通路。 6. 在天线阵列模块中添加射频接收器,该接收器可以接收到射频信号并进行相关处理。设置接收器的参数,如接收机灵敏度、频率带宽和解调方式等。 7. 连接天线阵列模块和接收器,建立起信号接收的通路。 8. 在模型中添加其他必要的射频模块,如射频放大器、滤波器和基带处理器等。 9. 对模型进行参数配置和仿真设置,如选择仿真时间、采样率和仿真方法等。 10. 运行模型进行仿真,观察天线阵列的性能和输出结果。 通过以上步骤,我们可以基于Simulink使用射频模块天线块对天线阵列的射频系统进行建模和仿真分析,以便更好地理解和优化射频系统的性能。
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值