필터 지우기
필터 지우기

SimulationInput cannot find my model

조회 수: 8 (최근 30일)
TeraWatt
TeraWatt 2023년 8월 1일
답변: Yatharth 2023년 8월 28일
Hello,
I need a quick help to understand why my code is not able to call for the model. My project folder has to internal folder, one called "SCRIPT" and the other called "MODEL" where the main simulation model resides (.slx). When I use the command:
in(i) = Simulink.SimulationInput('C:/ggit/test/Project/MODEL/PhC200.slx');
I get the following error:
Error using RunTestCasesEP100 (line 56)
Invalid ModelName,
'C:/ggit/test/Project/MODEL/PhC200.slx',
specified in the SimulationInput object.
ModelName must be a valid Simulink model
name.
why?? what is wrong?/
  댓글 수: 2
Paul
Paul 2023년 8월 1일
What is the result of this command
which PhC200.slx
Also, should the forward slashes (/) as the file name separators be backslashes (\) ?
TeraWatt
TeraWatt 2023년 8월 1일
found the isue. Need to enter ONLY the model name without file extention .slx,like this:
in(i) = Simulink.SimulationInput('C:/ggit/test/Project/MODEL/PhC200');

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

답변 (1개)

Yatharth
Yatharth 2023년 8월 28일
Hi, I understand that you want to run the Phc200.slx model located inside MODEL folder from a script that is located in the script folder.
To resolve this issue, you can try the following steps:
1. Instead of using the full file path, you can try specifying just the model name without the file extension. For example, if the model name is "PhC200.slx" and it resides in the "MODEL" folder, and your current MATLAB PATH is Project/MODEL you can use :
in(i) = Simulink.SimulationInput('PhC200');
2. Make sure that the current working directory in MATLAB is set to the project folder that contains the "SCRIPT" and "MODEL" folders. You can use the cd command to change the current working directory if needed.
3. if you are current working directory in MATLAB is either Project or Project/SCRIPT , you can use :
in(i) = Simulink.SimulationInput('MODEL/PhC200');

카테고리

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

제품


릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by