regression model in simulink function block

5 visualizzazioni (ultimi 30 giorni)
Djamel Guessoum
Djamel Guessoum il 30 Ott 2023
Commentato: Djamel Guessoum il 12 Nov 2023
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 Commenti
Sulaymon Eshkabilov
Sulaymon Eshkabilov il 30 Ott 2023
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 il 31 Ott 2023
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

Accedi per commentare.

Risposte (1)

Drew
Drew il 3 Nov 2023
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 Commento
Djamel Guessoum
Djamel Guessoum il 12 Nov 2023
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

Accedi per commentare.

Community Treasure Hunt

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

Start Hunting!

Translated by