Index exeeds matrix dimensions

1 visualizzazione (ultimi 30 giorni)
for n = 1:k
%HS or LE
prompt = 'Enter individual tasks memory location \n High Speed = 1 \n Low Energy = 0 \n';
fprintf('M(%d) = \n',n);
M(n) = input (prompt);
if M(n) == 1
h = h+1;
prompt = 'Enter the hiding value of high speed tasks \n';
fprintf('V(%d) = \n',h);
Vh(h) = input (prompt);
hst(h) = n;
else
l = l+1;
prompt = 'Enter the hiding value of low speed tasks \n';
fprintf('V(%d) = \n',l);
Vl(l) = input (prompt);
let(l) = n;
end
end
for n = 1:k
if M(n) == 1
a = 'High speed';
fprintf('M(%d) = %s \n',n,a);
else
b = 'Low Energy';
fprintf('M(%d) = %s \n',n,b);
end
end
fprintf('Number of High speed tasks = %d \n',h);
fprintf('Number of Low Energy tasks = %d \n',l);
for n = hst(1):hst(h)
fprintf('Vh(%d) = %d \n',n,Vh(n));
end
for n = let(1):let(l)
fprintf('Vl(%d) = %d \n',n,Vl(n));
end
Output
M(1) = High speed
M(2) = High speed
M(3) = High speed
M(4) = High speed
M(5) = Low Energy
M(6) = Low Energy
M(7) = Low Energy
Number of High speed tasks = 4
Number of Low Energy tasks = 3
Vh(1) = -100
Vh(2) = -1
Vh(3) = -2
Vh(4) = -3
Index exceeds matrix dimensions.
  3 Commenti
hariharan ilango
hariharan ilango il 17 Feb 2017
Number of tasks 7 Size of High Speed 3 Size of Low Energy 3 M(1) = Enter individual tasks memory location High Speed = 1 Low Energy = 0 1 V(1) = Enter the hiding value of high speed tasks -100 M(2) = Enter individual tasks memory location High Speed = 1 Low Energy = 0 1 V(2) = Enter the hiding value of high speed tasks -1 M(3) = Enter individual tasks memory location High Speed = 1 Low Energy = 0 1 V(3) = Enter the hiding value of high speed tasks -2 M(4) = Enter individual tasks memory location High Speed = 1 Low Energy = 0 1 V(4) = Enter the hiding value of high speed tasks -3 M(5) = Enter individual tasks memory location High Speed = 1 Low Energy = 0 0 V(1) = Enter the hiding value of low speed tasks 1 M(6) = Enter individual tasks memory location High Speed = 1 Low Energy = 0 0 V(2) = Enter the hiding value of low speed tasks 2 M(7) = Enter individual tasks memory location High Speed = 1 Low Energy = 0 0 V(3) = Enter the hiding value of low speed tasks 3 M(1) = High speed M(2) = High speed M(3) = High speed M(4) = High speed M(5) = Low Energy M(6) = Low Energy M(7) = Low Energy Number of High speed tasks = 4 Number of Low Energy tasks = 3 Vh(1) = -100 Vh(2) = -1 Vh(3) = -2 Vh(4) = -3 Vl(1) = 1 Vl(2) = 2 Vl(3) = 3 Maximum hiding value from HS = Vh(2) = -1 Number of High speed tasks = 3 Number of Low Energy tasks = 4 Vh(1) = -100 Vh(2) = -1 Vh(3) = -2 Vl(1) = 1 Vl(2) = 2 Vl(3) = 3 Index exceeds matrix dimensions.
Error in replacer2 (line 78) fprintf('Vl(%d) = %d \n',n,Vl(n));
>>
hariharan ilango
hariharan ilango il 17 Feb 2017
Line 78 fprintf('Vl(%d) = %d \n',n,Vl(n));

Accedi per commentare.

Risposta accettata

Walter Roberson
Walter Roberson il 17 Feb 2017
for n = 1:h
not
for n = hst(1):hst(h)
and likewise
for n = 1 : l
not
for n = let(1):let(l)

Più risposte (0)

Categorie

Scopri di più su Multicore Processor Targets 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!

Translated by