Problem using a .mat file with a standalone application (.exe)

1 次查看(过去 30 天)
Hello everyone,
I am trying to create an application to detect some pattern in EEG data. To do so, I did some classification learning (in the Classification Learner app) and exported the model so I can use it with new data. The model is exported as ModelLvl2.mat.
Then I created the application with Matlab GUI and every works perfectly when I test it with the .m file. But when I create the .exe file to launch the application, it won't work any more. When I used Matlab Compiler to create the .exe I did precise that ModelLvl2.mat was one of the files required for my application to run so it should be included in the .exe.
The file I want to use is called ModelLvl2.mat and I need to access ModelLvl2.ClassificationSVM. Here is my code :
load('ModelLvl2.mat');
model = ModelLvl2.ClassificationSVM;
labels = predict(model, data);
When I use the .exe everything works except that. I did some tests and found that the application loads ModelLvl2.mat file alright and it even contains ClassificationSVM. But inside ClassificationSVM there should be some more stuff and this stuff is not present with the .exe.
l = length(fieldnames(model))
It returns 0 with the .exe but it should normally return 33.
It would really help if someone had a solution to my problem. Thank you in advance !

回答(1 个)

Image Analyst
Image Analyst 2017-7-11
It's a path problem. You did not specify the complete path of your mat file so it's looking in the current folder. However the current folder is not where you think it is (where you installed the executable). Try to specify the full path.
  2 个评论
Caroline Aubert
Caroline Aubert 2017-7-16
Thank you for your answer. I tried specifying the path :
path = 'C:\Users\Caroline\Desktop\Training\K Complexes\Model1.mat';
p = load(path);
But it still doesn't work. I also tried some things on the link you gave me, as including it in a deployable tool. Nothing worked so far ...
Image Analyst
Image Analyst 2017-7-16
编辑:Image Analyst 2017-7-16
DO NOT use path as the name of a variable. It is a VERY IMPORTANT variable that you definitely do not want to overwrite/destroy. Choose another name. If that doesn't work, you may have to call tech support.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Introduction to Installation and Licensing 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by