Borrar filtros
Borrar filtros

regression model in simulink function block

1 visualización (últimos 30 días)
Djamel Guessoum
Djamel Guessoum el 30 de Oct. de 2023
Comentada: Djamel Guessoum el 12 de Nov. de 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 comentarios
Sulaymon Eshkabilov
Sulaymon Eshkabilov el 30 de Oct. de 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 el 31 de Oct. de 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

Iniciar sesión para comentar.

Respuestas (1)

Drew
Drew el 3 de Nov. de 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 comentario
Djamel Guessoum
Djamel Guessoum el 12 de Nov. de 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

Iniciar sesión para comentar.

Community Treasure Hunt

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

Start Hunting!

Translated by