How can I update the data in slx file without matlab/simulink?

조회 수: 32 (최근 30일)
Jitesh Patel
Jitesh Patel 2018년 8월 17일
댓글: Jitesh Patel 2018년 8월 17일
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
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
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.

추가 답변 (1개)

Walter Roberson
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.
  댓글 수: 1
Jitesh Patel
Jitesh Patel 2018년 8월 17일
Thank you - it worked. Sadly could not accept both answers at the same time.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Programmatic Model Editing에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by