필터 지우기
필터 지우기

What is the function behind renaming Simscape Blocks in the Simscape Results Explorer?

조회 수: 4 (최근 30일)
Hello I have created a script in Matlab making analyses and calculations out of Simulink/Simscape simulation by reading the 'simlog' variable. The problem is, that the Simscape Blocks are renamed in the structure of 'simlog' in the same way, as they are renamed in the Simscape Results Explorer. For instants 'Chamber 5' is renamed to 'Chamber_5'. Ok this is a easy example, which could be solved by replacing ' ' with '_'. But '1.1 - 1.2' is replaced by 'x1_1_1_2'. Now is my question, what is the function behind this renaming process? How can find out, which name my component will get in the 'simlog' variable. Thanks in advanced Cedric

채택된 답변

Sebastian Castro
Sebastian Castro 2015년 8월 20일
The rules that come into play here are not that bad, and all due to MATLAB's restrictions on variable names
  1. Non-alphabetic characters like spaces and dots get converted to underscores, which ARE allowed in MATLAB.
  2. Variable names cannot start with a number, so if your block starts with one then it appends an "x" in front of it.
I'd recommend keeping the block names simple, and using Block Annotations to add any fancy numbers and other characters.
- Sebastian
  댓글 수: 1
Cedric Götze
Cedric Götze 2015년 8월 20일
This little code solves the replacement:
simscape.logging.sli.findNode(simlog,'1.1 - 3.2').id
But still thank you for your help!

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

추가 답변 (1개)

Steven Lord
Steven Lord 2015년 8월 20일
Variable names in MATLAB must start with a letter. That string looks like it was created using matlab.lang.makeValidName or perhaps genvarname.
  댓글 수: 1
Cedric Götze
Cedric Götze 2015년 8월 20일
Yes, you are right. Thank you
S = {'a%name', 'name_1', '2_name'};
N = matlab.lang.makeValidName(S)
This code is also a solution, but in my case i prefer the one at the answer above!

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

카테고리

Help CenterFile Exchange에서 Physical Units에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by