Simulation stopped due to out of bounds error
1 view (last 30 days)
Show older comments
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 Comments
Kaustubha Govind
on 29 Nov 2012
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);
Answers (0)
See Also
Categories
Find more on Event Functions in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!