How to call load_system function with the path as a variable ?

조회 수: 2 (최근 30일)
Nouran Adel
Nouran Adel 2019년 7월 3일
댓글: Nouran Adel 2019년 7월 29일
I'm trying to get information from a simulink model to the matlab workspace then to java gui . so in java I use a matlab engine to open matlab session then I use evalAsync to execute matlab commands . first I load the simulink model using : load_system function , this works well if I include the path itself when calling the function like : load_system('C:/Users/nouu_/Desktop/untitled.slx') . But what if I want to call the function with the path as a variable like : load_system(p) and the path is stored in the variable p ?? this doesn't work with me . The idea is that I get the path as an input from the user in java gui so I store it in a variable then pass this variable to matlab workspace and load the system . what's the data type of the parameter "sys" of the function : load_system (sys) ?? I store the path in a string variable maybe it shouldn't be string and that's why I get an error !
this is the error :
java.lang.IllegalStateException: Blocking in Event Dispatch Thread not allowed
at com.mathworks.mvm.exec.FutureResult.waitInternal(FutureResult.java:316)
at com.mathworks.mvm.exec.FutureResult.get(FutureResult.java:261)
at com.mathworks.engine.FutureResult.get(FutureResult.java:44)
at com.mathworks.engine.MatlabEngine.putVariable(MatlabEngine.java:530)
  댓글 수: 2
Shameer Parmar
Shameer Parmar 2019년 7월 3일
Yes, the datatype of the variable 'sys' should be string..
So try to store single string value into your variable sys, including the filename with its extension.. i.e. fullpath/directory + filename + extension.. this should be in single inverted commas.. as a signle string value to your variable 'sys'..
Nouran Adel
Nouran Adel 2019년 7월 29일
yes it worked , thanks a lot :)

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

답변 (0개)

카테고리

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