I was working on Matlab R2015a's Classification Learner Toolbox. I successfully imported the file data and export it using Export Model, and i got a structure named trainedClassifier. But while running its showing the following error
Show older comments
matlab code clc; clear all; close all; a= readtable('input.csv'); height = [167; 152; 150; 159; 275; 285; 200; 253]; T =height; yfit = predict(trainedClassifier, T{:,trainedClassifier.PredictorNames})
error Undefined function or variable 'trainedClassifier'.
Error in check (line 7) yfit = predict(trainedClassifier, T{:,trainedClassifier.PredictorNames})
1 Comment
Ceethal Kottakali Piyus
on 24 Oct 2017
Accepted Answer
More Answers (1)
Roya Salehzadeh
on 7 Nov 2022
0 votes
Hi,
I have trained a classifier in MATLAB 2022 and saved it. I need to load the trained classifier inside a matlab function in Simulink (non in an m.file ) in MATLAB 2015a, and then use predict() fucntion. . Do you have any idea on how I should do that?
These commands work fine for the MATLAB 2022, when I use them inside the matlab function of Simulink block but they are not available for MATLAB 2015a:
- saveLearnerForCoder()
- loadLearnerForCoder()
For MATLAb 2015a, I tried to save the classifier in MATLAB 2022a as a mat file and then load the matin MATLAB 205a file and use predict function. It works when use these commands in command window or m.file, but When I use these inside the simulink matlab function I recieve an error.
function label = svmIonospherePredict(XTest) %#codegen
load('MdlLinear.mat'); %%% this loads an object
[label] = predict(MdlLinear,XTest);
end
- The output of a call to 'load' is not assigned to a variable. Assign its output to a variable without subscripting.
- Undefined function or variable 'MdlLinear'.
Categories
Find more on Classification Learner App 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!