Simulation stopped due to out of bounds error
1 次查看(过去 30 天)
显示 更早的评论
Hi, I'm running the next code into embedded matlab block from simulink, but when I run it, I have the next error message Simulation stopped due to out of bounds error, Enable debugging to pinpoint the location of the error.
I did enable debugging and it keeps pinpoint the line of D(s,:) = inf , until I stopped appears the same error message Simulation stopped due to out of bounds error. Block Embedded MATLAB Function (#19) While executing: none.
Can anyone please help me with this..
x=(54,2);
function D = distmat(X)
%DISTMAT Compute euclidian distance matrix from coordinates
[n,dim] = size(X);
D = zeros(n);
for j = 1:n
for k = 1:dim
v = X(:,k) - X(j,k);
D(:,j) = D(:,j) + v.*v;
end
end
D = sqrt(D);
%--------------------------------------------------------------
function p = greedy(s,D)
n = size(D,1);
p = zeros(1,n,'uint16');
p(1) = s;
for k = 2:n
D(s,:) = inf;
[junk,s] = min(D(:,s));
p(k) = s;
end
3 个评论
Kaustubha Govind
2012-11-29
Ah! So that's the problem. You need to make sure 's' is an integer. You can't index with a non-integer. For example, you can't do:
x = zeros(2);
y = x(0.2);
回答(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!