Someone, please help me...I'm working on an EEG classifier based project for that this Classification Learner Toolbox will be a great help, but I got stuck in the very beginning...
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
2 views (last 30 days)
Show older comments
Ceethal Kottakali Piyus
on 20 Oct 2017
Answered: Roya Salehzadeh
on 7 Nov 2022
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})
Accepted Answer
Sean de Wolski
on 24 Oct 2017
trainedClassifier is not in your workspace because you have a clear all at the beginning of the script which is clearing it.
I would recommend saving it after exporting and then loading in the script
Export from app.
save trainedClassifier.mat trainedClassifier
In script
load trainedClassifier.mat
predict(etc...)
More Answers (1)
Roya Salehzadeh
on 7 Nov 2022
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'.
0 Comments
See Also
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!