I have a knn classification model.i want to simulate the same in simulink

조회 수: 3 (최근 30일)
pavan sunder
pavan sunder 2016년 12월 13일
댓글: Sean de Wolski 2016년 12월 14일
I have a knn simulation model. I used functions fitcknn and predict in my script...i want to simulate the same in smulink..kindly suggest me which block to be used for fitcknn and predict in simulink

답변 (1개)

Sean de Wolski
Sean de Wolski 2016년 12월 13일
You could use the MATLAB function block to call your KNN model from Simulink.
  댓글 수: 2
pavan sunder
pavan sunder 2016년 12월 14일
편집: pavan sunder 2016년 12월 14일
i tried the same not working. i am unable take the KNN model as input. kindly help me with a more detail explanation..
i wrote the following code in my matlab function block
function y = KNNclass(mdl2,ts)
y=predict(mdl2,ts);
end
the error messagee i received is
Unsupported input format for From Workspace block 'tt/From Workspace'. Available formats are double non-complex matrix, a structure with or without time, or a structure with MATLAB timeseries as leaf nodes. All formats require the data to be finite (not Inf or NaN).
Sean de Wolski
Sean de Wolski 2016년 12월 14일
It shouldn't be in the from workspace block, it should be in a MATLAB function block. Here's how I would set it up. Note that the knn classifier is already trained and stored in a MAT file. You could swap that out to a call to train it if necessary.

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

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by