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

KSSV
KSSV 2017년 2월 17일
We cannot help you unless variables inside are known to us..
hariharan ilango
hariharan ilango 2017년 2월 17일
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 2017년 2월 17일
Line 78 fprintf('Vl(%d) = %d \n',n,Vl(n));

댓글을 달려면 로그인하십시오.

 채택된 답변

Walter Roberson
Walter Roberson 2017년 2월 17일

0 개 추천

for n = 1:h
not
for n = hst(1):hst(h)
and likewise
for n = 1 : l
not
for n = let(1):let(l)

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Matrices and Arrays에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by