convert m file into simulink model
2 views (last 30 days)
Show older comments
Hallo everyone!
I want to convert a m file into simulink model, which will be later connected with Digsilent Power Factory.I chose matlab funtion.
treeensmeble is a struct and I have already saved it as a mat file. It has two feild in treeensemble, I just use one "trees". I want to load it into the funtion. But there is an error: Undefined function or variable 'treeensemble'.
The code is as below:
function [YTS]=rtenspred(XTSA)
coder.extrinsic('load')
load treeensemble
verbose=0;
persistent XTS;
persistent tree;
XTS=XTSA;
Nts=size(XTS,1);
T=length(treeensemble.trees);
YTS=0;
for t=1:T
if (verbose)
fprintf('t=%d\n',t);
end
tree=treeensemble.trees(t);
YTS=YTS+tree.weight*rtpred();
end
0 Comments
Answers (1)
Walter Roberson
on 31 Aug 2015
data = load('treeensemble.mat');
treeensemble = data.treeensemble;
2 Comments
Walter Roberson
on 31 Aug 2015
I think to fix this, you are going to first assign treeensemble a struct() . I do not know if
treeensemble = struct();
will be enough, or if you will need to assign it with all of the fields, something like
treeensemble = struct('trees', [], 'weights', []);
See Also
Categories
Find more on Simulink Environment Customization in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!