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

5 vues (au cours des 30 derniers jours)
Nouran Adel
Nouran Adel le 3 Juil 2019
Commenté : Nouran Adel le 29 Juil 2019
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 commentaires
Shameer Parmar
Shameer Parmar le 3 Juil 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'..
Nouran Adel
Nouran Adel le 29 Juil 2019
yes it worked , thanks a lot :)

Connectez-vous pour commenter.

Réponses (0)

Catégories

En savoir plus sur Programmatic Model Editing dans Help Center et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by