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 (최근 30일)
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
Ceethal Kottakali Piyus
Ceethal Kottakali Piyus 2017년 10월 24일
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...

댓글을 달려면 로그인하십시오.

채택된 답변

Sean de Wolski
Sean de Wolski 2017년 10월 24일
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...)

추가 답변 (1개)

Roya Salehzadeh
Roya Salehzadeh 2022년 11월 7일
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'.

카테고리

Help CenterFile Exchange에서 Classification Learner App에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by