Function "ismember" in Simulink?
2 次查看(过去 30 天)
显示 更早的评论
Dear community,
I would like to know if there is a way to get a function like "ismember" to work in Simulink? In my program I have to find same points in an array. I have tried to create a workaround myself:
function index = find_same_points( A , B )
%create empty matrix
index_matrix = zeros(size(A,1), 3);
%comepare each row from one martix with the other
for i = 1 : size(A,1)
for j = 1 : size(B,1)
index_matrix(i,j) = A(i,1) == B(j,1)...
& A(i,2) == B(j,2)...
& A(i,3) == B(j,3);
end
end
index = any(index_matrix,2) ;
end
It always gives me the following error:
Runtime error: Index into array out of range Model Name: function_tester Block Name: function_tester/MATLAB Function Attempted to access 4 element of data index_matrix. The valid index range is 1 to 3 Please note that the simulation will be aborted immediately after you continue from this breakpoint to avoid segmentation violations.
Unfortunately I have no idea how to fix this... Please help!!!!
0 个评论
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Event Functions 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!