Unable to run the predict function
Show older comments
Hi,
I have created a Model by training. Now I want to use the model for predicting. Property sheet shows me three menus: ModelName, ModelName.predictFcn and ModelName.HowtoPredict. ModelName.HowtoPredict showed me a line of text like:
yfit = C.predictFcn(T)
and some more text. I replaced the line to the following:
yfit = ModelName.predic(testdata);
but I am getting following errors:
run(GTM3_Acc62p8.HowToPredict);
Error using run (line 66)
yfit = GTM3_Acc62p8.predictFcn(testdata); not found.
Somebody please gide me.
Zulfi.
3 Comments
Zulfiqar Khan
on 1 Dec 2018
Walter Roberson
on 1 Dec 2018
GTM3_Acc62p8 appears to be a struct and GTM3_Acc62p8.HowToPredict appears to contain a character vector that appears to be in the form of a function call with an assignment to yfit. And you appear to be attempting to run(GTM3_Acc62p8.HowToPredict) and so appear to be attempting to run() a character vector that is a MATLAB statement.
run() is not used to execute MATLAB statements that are in character vectors or character arrays. run() must be provided with a file name (possibly qualified) and it causes the content of the file to be evaluated.
If you have a character vector that you want to execute, the MATLAB function is eval().
However, most of the time you should avoid eval() and instead create functions, possibly together with function handles.
Zulfiqar Khan
on 1 Dec 2018
Answers (0)
Categories
Find more on Install Products 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!