Classification Learner App Backward Compatibility

조회 수: 1 (최근 30일)
Mohamed
Mohamed 2025년 4월 16일
댓글: Mohamed 2025년 4월 22일
I have trained a coarse tree model using R2024b and it has been exported to simulink and integrated to a system. I need to export the whole system including the learner subsystem to R2018b. When I did that, The learner subsystem became empty, even though from what I know is that coarse tree is supported in R2018b. Are models not backward compatible? If not all of them, then what models are backward compatible from R2024b to R2018b?
Thanks in advance!

채택된 답변

Shantanu Dixit
Shantanu Dixit 2025년 4월 22일
편집: Shantanu Dixit 2025년 4월 22일
Hi Mohamed, If I understood the query correctly you are using 'Export Model' option to export the tree model to Simulink, which generates a Simulink subsystem with a dedicated block (eg. 'ClassificationTree Predict' block: https://www.mathworks.com/help/stats/classificationtreepredict.html).
While the tree model itself (here 'ClassificationTree') is supported in R2018b, the Simulink Prediction blocks (e.g., 'ClassificationTree Predict') are not available in older releases. Specifically 'ClassificationTree Predict' and'RegressionTree Predict' block were introduced in R2021a, which might be the reason that older MATLAB version might not be recognizing them, resulting in empty subsytems.
As a workaround, you can replace the unsupported prediction block with a MATLAB function block that calls the 'predict' method of the tree model. You can refer to the following documentation https://www.mathworks.com/help/stats/predict-class-labels-using-matlab-function-block.html which details on using a MATLAB function for predicting labels from an ML model.
Hope this helps!
  댓글 수: 1
Mohamed
Mohamed 2025년 4월 22일
Thank you!
It seems that R2018b does not support saveLearnerForCoder and does not support loadLearnerForCoder as well. I used saveCompactModel and loadCompactModel instead. The function I am using is below:
function label = predictTree(features)
%#codegen
persistent treeModel;
if isempty(treeModel)
% Load the saved compact model (codegen-compatible)
treeModel = loadCompactModel('CompactTreeModel.mat');
end
% Predict the label using the loaded model
label = predict(treeModel, features);
I tried several workarounds using the MATLAB function block but I am getting errors unfortunately that I am not understanding.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Subsystems에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by