许可优化
许可优化
产品
产品
解决方案
解决方案
服务支持
服务支持
关于
关于
软件库
当前位置:服务支持 >  软件文章 >  SPS仿真文件转换到新版MATLAB方法

SPS仿真文件转换到新版MATLAB方法

阅读数 3
点赞 0
article_banner


% 如何将黑库仿真文件转换到新版MATLAB

%Specify the name of the original model you want to convert and open the model.

originalModelName = "myModelName";

open_system(originalModelName);

%To capture all relevant data during the simulation, add signal logging to all the scope inputs in the model. To find all Scope blocks in the model, use the find_system function and set the BlockType input argument to "Scope". Mark the input signals of these blocks for logging.

%If the original model does not contain any Scope blocks, to help confirm the conversion process, add Scope blocks to the model and connect them to signals of significant interest.

MATLAB方法

scopes = find_system(originalModelName,BlockType="Scope");

for scopeIdx = 1:height(scopes)

thisScope = scopes{scopeIdx};

lines = get_param(thisScope,"LineHandles");

lines = lines.Inport;

for lineIdx = 1:length(lines)

thisLine = lines(lineIdx);

Simulink.sdi.markSignalForStreaming(thisLine,"on");

end

end

%To retain these changes, save the updated model.

save_system(originalModelName);

%Log results by running a simulation of the original model.

sim(originalModelName);

%Use the spsConversionAssistant function to replace the Specialized Power Systems blocks in the model with Simscape Electrical blocks.

spsConversionAssistant(originalModelName);

%The function creates a new file named myModelName_simscape and saves it and the conversion HTML report in the current folder.

%Files pane containing the files generated by the spsConversionAssistant function. The first file is the HTML report, the second file is the converted model, and the third file is the original model.

%Review the HTML report, inspect replaced blocks for correctness, and manually convert unsupported blocks to Simscape and Simscape Electrical blocks.

%Open the converted model.

convertedModelName = originalModelName+"_simscape";

open_system(convertedModelName);

%Log results by running the converted Simscape model.

sim(convertedModelName);

%Compare the outputs of the original and converted models. This comparison helps you identify any discrepancies between the two sets of results. Consider setting the absolute and relative tolerances to values that make sense for your model.

absoluteTolerance = 1e-3;

relativeTolerance = 0.01;

timeTolerance = 1e-3;

runIDs = Simulink.sdi.getAllRunIDs;

runDiff = Simulink.sdi.compareRuns(runIDs(end-1,1),runIDs(end,1),...

abstol=absoluteTolerance,...

reltol=relativeTolerance,...

timetol=timeTolerance);

%Visualize the differences between the original and converted model outputs. The visualization shows the tolerances so you can observe if the differences are within these tolerances. This step provides a clear view of how the models compare and highlights any significant variations in their behavior.

Simulink.sdi.view(Simulink.sdi.GUITabType.CompareRuns);

%If the original and converted model outputs are considerably different, further investigate the model to determine whether the discrepancies are acceptable. If the differences occur at the start of the simulation, they might be caused by initialization differences. If you observe differences in other signals, review the HTML report to determine whether they result from converted blocks that are only partially supported.


免责声明:本文系网络转载或改编,未找到原创作者,版权归原作者所有。如涉及版权,请联系删

相关文章
技术文档
QR Code
微信扫一扫,欢迎咨询~
customer

online

联系我们
武汉格发信息技术有限公司
湖北省武汉市经开区科技园西路6号103孵化器
电话:155-2731-8020 座机:027-59821821
邮件:tanzw@gofarlic.com
Copyright © 2023 Gofarsoft Co.,Ltd. 保留所有权利
遇到许可问题?该如何解决!?
评估许可证实际采购量? 
不清楚软件许可证使用数据? 
收到软件厂商律师函!?  
想要少购买点许可证,节省费用? 
收到软件厂商侵权通告!?  
有正版license,但许可证不够用,需要新购? 
联系方式 board-phone 155-2731-8020
close1
预留信息,一起解决您的问题
* 姓名:
* 手机:

* 公司名称:

姓名不为空

姓名不为空

姓名不为空
手机不正确

手机不正确

手机不正确
公司不为空

公司不为空

公司不为空