Simulation stopped due to out of bounds error
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
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 Commenti
Kaustubha Govind
il 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);
Risposte (0)
Vedere anche
Categorie
Scopri di più su Event Functions in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!