Use exhaustive searcher in simulink model

3 Ansichten (letzte 30 Tage)
leonidas86
leonidas86 am 30 Sep. 2021
Beantwortet: Salman Ahmed am 12 Okt. 2021
Hello,
I would like to use the ExhaustiveSearcher() function in simulink by using a matlab function block. The target is to determine the nearest point in x-y- data set with reference to a given x-y-coordinate.
When running in Matlab the function works fine but in simulink I get an error "Cannot call protected member" when initializing the Mdl object.
Here is my code so far:
function [x,y] = getNearestPoint(xNED_Veh, yNED_Veh, xNED_Track, yNED_Track)
xyNED_Track = [xNED_Track yNED_Track];
Mdl = ExhaustiveSearcher(xyNED_Track);
Idx = knnsearch(Mdl,[xNED_Veh yNED_Veh]);
x = xNED_Track(Idx);
y = yNED_Track(Idx);
end

Antworten (1)

Salman Ahmed
Salman Ahmed am 12 Okt. 2021
Hi,
You may try defining the function using coder.extrinsic in case the function is not supported. Try adding the following to your MATLAB Fcn block.
coder.extrinsic('ExhaustiveSearcher');
You may also consider preallocating some memory to Idx using coder.nullcopy. Try adding this line also, if you face any errors.
Idx = coder.nullcopy(zeros(s)); % replace s with the expected size of Idx

Kategorien

Mehr zu Modeling finden Sie in Help Center und File Exchange

Produkte


Version

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by