Why do I receive an error when executing a standalone application that loads a Dataset object and is built using the MATLAB Compiler 4.11 (R2009b)?

3 views (last 30 days)
I am compiling MATLAB code which loads a Dataset object from a MAT file. For example, I have generated a MAT file using the following code:
NumObs = 5;
NameObs = strcat({'Obs'},num2str((1:NumObs)','%-d'));
meas = [ ...
5.1 3.5 1.4 0.2
4.9 3 1.4 0.2
4.7 3.2 1.3 0.2
4.6 3.1 1.5 0.2
5 3.6 1.4 0.2];
iris = dataset({nominal(repmat({'setosa'},NumObs,1)),'species'},...
{meas,'SL','SW','PL','PW'},...
'ObsNames',NameObs);
display(iris);
save iris
And I have compiled the below code which loads a dataset object, as saved
function testload
load iris
display(iris.SW('Obs1'));
However, I receive the following error when executing my compiled application.
Warning: Variable 'iris' originally saved as a dataset cannot be instantiated
as an object and will be read in as a uint32.
> In testload at 3
??? Attempt to reference field of non-structure array.
Error in ==> testload at 4

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 18 Oct 2013
To load a Dataset object, the Dataset class definitions are required to be on the MATLAB path. Since the class definitions are not natively on the MCR path, you have to do this explicitly. You can recruit the class definitions into the CTF by using the function pragma
%# function
as shown in the example below:
function testload
%#function dataset
load iris
display(iris.SW('Obs1'));

More Answers (0)

Products


Release

R2009b

Community Treasure Hunt

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

Start Hunting!