Clear Filters
Clear Filters

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

11 views (last 30 days)
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 Comments
Shameer Parmar
Shameer Parmar on 3 Jul 2019
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'..

Sign in to comment.

Answers (0)

Categories

Find more on Simulink Functions in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!