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)?
4 次查看(过去 30 天)
显示 更早的评论
MathWorks Support Team
2010-2-10
编辑: MathWorks Support Team
2014-10-17
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
采纳的回答
MathWorks Support Team
2013-10-18
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'));
0 个评论
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!