Filter löschen
Filter löschen

Variable is undefined on some execution paths.

2 Ansichten (letzte 30 Tage)
Emmanuel Luevano
Emmanuel Luevano am 27 Nov. 2012
hello guys!
I hope somebody can advise me with respect the next code, when I run it into embedded editor from simulink embedded block, I have the error that Variable 'pmin' is undefined on some execution paths.
How should I define it if p = uint16
Lmin = inf;
L = 0;
for k = 1:m
% Nearest neighbour tour
p = greedy(s(k),D);
% Improve tour by 2-opt heuristics
[p,L] = exchange2(p,D);
% Keep best tour
if L < Lmin
Lmin = L;
pmin = p;
end
end
% Output
p = double(pmin);
L = Lmin;
I want to the outputs take the value of the If routine. greetings!!

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 27 Nov. 2012
Add
p = uint16(0)
at the top.
Your current code does not define pmin in the case that m < 1

Weitere Antworten (0)

Community Treasure Hunt

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

Start Hunting!

Translated by