Deploying Matlab gui exe with Weka Models - matlab

My problem is that when i deploy my Program along with weka models. The resulting error is that it cant read the weka model file.
Here is the structure of the Files
ModelLoadmodel.m
Contains The ff code
javaaddpath('weka.jar');
addpath('SurfModels');
loadedModel = wekaLoadModel('RandomForestK40Surf.model');
The Folder wherein all of these file contains has a structure of
WekaLoadmodel.m
SurfRandomForestK40.model
Folder"WekaLab" which has a
WekaLoadModel.m
Weka.jar
When i try to use the commandline function of
loadedModel = wekaLoadModel('RandomForestK40Surf.model');
The loadedModel is successfully loaded but when i deploy it using deploytool and the output is Error reading model file
The WekaLoadmodel.m Contains
if ~exist(filename, 'file')
error('WEKALAB:wekaLoadModel:FileNotFound', 'No file found at %s', filename);
end
%% Code
try
modelObj = weka.core.SerializationHelper.read(filename);
catch err
error('WEKALAB:wekaLoadModel:ReadError', 'Error reading model file at %s', filename);
end
end
It came from https://www.mathworks.com/matlabcentral/fileexchange/58675-wekalab--bridging-weka-and-matlab . Is there some sort of problem when loading other file extension in matlab deploytool?

The answer is don't put it in a folder. Just take all the .m files and compile it. Simple as that

Related

How to read .mat files in EEGLab?

I am trying to read SEED Dataset in EEGLAB. The files are in .mat format. I am getting the error as --- EEGLAB error in function pop_loadeeg() at line124.Output argument "accept" and maybe others not assigned during call to "F:eeglab2019\plugins\neuroscanio1.3\loadeeg.m>loadeeg".
How to read the .mat file of EEG SEED Dataset in EEGLAB ? Please guide.
I hope this help:
Run eeglab.m, next in the pop up window: file->import data -> using EEGLAB functions and plugins -> from ASCII/float file or Matlab array.
Almost you can check the tutorial in the official EEGLAB page.
https://sccn.ucsd.edu/wiki/A01:_Importing_Continuous_and_Epoched_Data

Simulink Coder: How to specify custom C files from script when generating C code?

I have a script that does some post processing of the initial code generated by Simulink coder. It creates an additional.c file that I wish to add into the build process. I want to add the file into the build process from a script, so I am following the docs here.
So my script looks like:
slbuild(gcs);
% generate additional.c file using files created by slbuild()
% ...
% now attempt to add additional.c to the build process as custom code
configs = getActiveConfigSet(gcs);
configs.set_param('SimUserSources', 'additional.c');
% now rebuild
slbuild(gcs)
I can verify that the config set is updated by:
checkConfigIsSet = configs.get_param('SimUserSources');
disp(checkConfigIsSet); % prints: additional.c
However, the coder does not appear to pick up this new config. When I click on the Configuration settings at the time of code generation: click to open section of the Code Generation report, I see the config value was not updated and additional.c was not compiled into the model.
What am I doing wrong please?
SimUserSources are for simulation builds used by blocks like MATLAB Function block and Stateflow. For code generation, you need to set the param "CustomSource". Try,
slbuild(gcs);
% generate additional.c file using files created by slbuild()
% ...
% now attempt to add additional.c to the build process as custom code
configs = getActiveConfigSet(gcs);
configs.set_param('CustomSource', 'additional.c');
% now rebuild
slbuild(gcs)

dicomrt2matlab - how to load data after conversion

I am using the program dicomrt2matlab. I was able to convert the dicom RT structure into matlab and I got the .mat file as well. How do I load the .mat file into matlab next? How can I see the RT information in my applied to my dicom files ?
Link - https://github.com/ulrikls/dicomrt2matlab
if you do data=load('myfilename.mat'); data will contain everything on it.
It shoudl have (I think) the following 3 data on it: 'contours', 'rtssheader', 'imageheaders'
you can access it as data.imageheaders

save vector as Matlab file

Does the save function in Matlab save the thing saved in the same project file?
I'm trying to save a vector as 'mat' file.
This is my code :
function facePts = getFacePts(faceFileName)
if(exist('faceFileName','file')==2)
facePts=load('faceFilename.mat');
return;
end
img=imread(faceFileName,'tif');
showImage(img);
[x,y]=ginput(3);
facePts=[x,y]';
facePts=facePts(:);
save faceFileName.m, facePts; %%%%% HERE
end
The function compiles but I can't find the file I saved
I guess you want to do this:
save('faceFileName.mat', 'facePts');
Ok, so I figuered out that the path of the current folder wasn't the path of my Project.
I changed that by going to 'Desktop' in the Bar, checked 'Current Folder' and chaged the path there.
Now it works !

How to load a .mat file and set the variable name in Octave or Matlab?

Apparently Matlab load loads the data from a .mat file into the variable that it was saved.
How can you load a single matrix from a .mat or binary file into an arbitrary variable?
Load it in to a struct and pop it out to your variable.
saved_name = 'varname_it_was_saved_as';
s = load('some_file.mat', saved_name);
my_new_variable = s.(saved_name);
I always use the struct forms of save and load for production code. It's cleaner because it doesn't dynamically fiddle with your workspace.
See help load for details.