필터 지우기
필터 지우기

regression model in simulink function block

조회 수: 1 (최근 30일)
Djamel Guessoum
Djamel Guessoum 2023년 10월 30일
댓글: Djamel Guessoum 2023년 11월 12일
Hi everyone. I need your help please . now for more than two weeks I cannot resolve the issue I have. I have trained a model for regression in regression learner and I have exported the trained model to my workspace and saved it as required and I have created a function to predict as mentioned in matlab website but when I use it in the simulink function block It doesnt work I have tried all possible ways mentioned in matlab website. please help. thanks
  댓글 수: 2
Sulaymon Eshkabilov
Sulaymon Eshkabilov 2023년 10월 30일
Some clarifcations are needed.
Q1: Can you share your model?
Q2: what simulink fcn were you trying to use?
Q3: what execise are you referring in MathWorks website or help documentation?
Djamel Guessoum
Djamel Guessoum 2023년 10월 31일
this is the function i have inserted in the function block:
function ypred = mypredict_boosted_trees(tb)
%#function fitrtree
load('boosted_trees_model.mat');
ypred = trainedModel_boosted_trees.predictFcn(tb);
end
the errors received are:
The output of a call to 'load' is not assigned to a variable. Assign its output to a variable without subscripting.
Function 'MATLAB Function2' (#138.65.96), line 3, column 1:
"load('boosted_trees_model.mat')"
Launch diagnostic report.
Component:MATLAB Function | Category:Coder error
Undefined function or variable 'trainedModel_boosted_trees.predictFcn'.
Function 'MATLAB Function2' (#138.106.147), line 4, column 9:
"trainedModel_boosted_trees.predictFcn(tb)"
Launch diagnostic report.
Component:MATLAB Function | Category:Coder error
Errors occurred during parsing of 'Voltage_maximum_function/MATLAB Function2'.
Component:MATLAB Function | Category:Coder error
Simulink cannot determine sizes and/or types of the outputs for block 'Voltage_maximum_function/MATLAB Function2' due to errors in the block body, or limitations of the underlying analysis. The errors might be inaccurate. Fix the indicated errors, or explicitly specify sizes and/or types for all block outputs.
Component:MATLAB Function | Category:Coder error
Simulink cannot determine sizes and/or types of the outputs for block 'Voltage_maximum_function/MATLAB Function2' due to errors in the block body, or limitations of the underlying analysis. The errors might be inaccurate. Fix the indicated errors, or explicitly specify sizes and/or types for all block outputs.
Component:Simulink | Category:Model error
Error in port widths or dimensions. Invalid dimension has been specified for input 'tb'.
Component:Simulink | Category:Model error

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

답변 (1개)

Drew
Drew 2023년 11월 3일
MathWorks provides Simulink blocks for machine learning model prediction. So, rather than using a generic MATLAB function block for the model prediction, you can use the native Simulink block designed for model prediction for your machine learning model. Check the "Blocks" section of the doc page https://www.mathworks.com/help/stats/code-generation.html.
Given that your model is named "boosted_trees_model.mat", the matching Simulink block is probably the "RegressionEnsemble Predict" block:
If this answer helps you, please remember to accept the answer.
  댓글 수: 1
Djamel Guessoum
Djamel Guessoum 2023년 11월 12일
first of all thanks for your response and time given. I have tried to use the proper simulink block which is the regressionensemble block where i have updated with the saved model but it did not recognize it when i click refresh . still not working. ...thanks

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

카테고리

Help CenterFile Exchange에서 Gaussian Process Regression에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by