How can I update the data in slx file without matlab/simulink?
37 次查看(过去 30 天)
显示 更早的评论
I am trying to automate few things and as a part of this, I want to change few things from the SLX model. I am aware that the SLX files are zipped files based on OPC format. So the question is - is it possible to extract the slx files in a folder, modify the content, zip it back and rename to slx?
I am getting error on performing the above steps as shown below: "Error using open (line 145) File 'C:\Test.slx' does not contain a valid Simulink model in SLX format: Content types stream does not exist"
Is there any particular setting that I need to set in 7zip to create the zip archive?
Regards and Thanks, Jitesh
1 个评论
Haritha
2018-8-17
first, extract the zipped files and in the main window, we have an option to browse for a folder. Then open the slx file now run it. If you have the same problem again means some blocks are updated from lower version to higher version.
采纳的回答
ES
2018-8-17
Its much simpler.. When you zip again, dont select the whole folder. Select the sub-folders and zip.
In other words, when you zip it after your changes, and double click, you should see _rels, metadata, simulink, [Content_Types].xml within the zip AND NOT A FOLDER which inturn has the above folders.
0 个评论
更多回答(1 个)
Walter Roberson
2018-8-17
I followed these steps on my Mac:
!cp /Applications/MATLAB_R2018a.app/toolbox/physmod/powersys/powerdemo/power_electronics/power_switch.slx .
!unzip power_switch.slx
cd simulink
edit blockdiagram.xml
Change InstanceData for AC Voltage Source: Amplitude from 120*sqrt(2) to 120*sqrt(3), Phase from 0 to 1. Save.
cd ..
!zip -r new_power_switch.slx '[Content_Types].xml' _rels metadata simulink
open_system('new_power_switch.slx')
The properties of the AC Voltage Source were indeed updated.
On Windows systems, you would probably need slightly different commands.
The -r option of zip is important for this purpose. It is the "recursive" option, saying that all files and directories underneath the explicitly named ones should be included.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Programmatic Model Editing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!