if-else condition not working inside for loop in latex
up vote
0
down vote
favorite
I want to write if-else conditions inside the for-loop in my algorithm using LaTex. The problem that is if-else do not appear in the algorithm and then not working.
Here my LaTex code:
usepackage[pdftex]{graphicx}
%usepackage{float}
usepackage{amsmath}
%usepackage{algorithm}
usepackage{algorithmic}
%usepackage{algorithm2e}
usepackage[ruled,vlined,linesnumbered,noresetcount]{algorithm2e}
begin{document}
begin{algorithm}[H]
DontPrintSemicolon
SetAlgoLined
%KwResult{Write here the result}
SetKwInOut{Input}{Input}SetKwInOut{Output}{Output}
Input{input vector <$in_{vec}$>}
Output{output vector <$out_{vec}$>}
%BlankLine
Put threshold vector <$V_{thr}$>:~
($thr_{1}$,~$thr_{2}$,~$thr_{3}$,~......~,~$thr_{n}$);
For{$ith$ threshold in <$V_{thr}$> from i=1 to n}{
BlankLine
For{j=1 to length < $in_{vec}$>}{
IF{condition}
STATE $out_{vec}$ ~ leftarrow~ $[out_{vec}(i) + 1]$;
else
STATE $$out_{vec}$ ~ leftarrow~ $[out_{vec}(i) + 0]$;
}
text{$All data $leftarrow$ [Data_{1} + Data_{2}]$};
text{Label $All data $ with "1" and "0"};
}
text{Get $out_{vec}$ vector}
caption{Inutp output algorithm}
label{algorithm2}
end{algorithm}
end{document}
Output:
Why if and else conditions not working???
algorithmic
add a comment |
up vote
0
down vote
favorite
I want to write if-else conditions inside the for-loop in my algorithm using LaTex. The problem that is if-else do not appear in the algorithm and then not working.
Here my LaTex code:
usepackage[pdftex]{graphicx}
%usepackage{float}
usepackage{amsmath}
%usepackage{algorithm}
usepackage{algorithmic}
%usepackage{algorithm2e}
usepackage[ruled,vlined,linesnumbered,noresetcount]{algorithm2e}
begin{document}
begin{algorithm}[H]
DontPrintSemicolon
SetAlgoLined
%KwResult{Write here the result}
SetKwInOut{Input}{Input}SetKwInOut{Output}{Output}
Input{input vector <$in_{vec}$>}
Output{output vector <$out_{vec}$>}
%BlankLine
Put threshold vector <$V_{thr}$>:~
($thr_{1}$,~$thr_{2}$,~$thr_{3}$,~......~,~$thr_{n}$);
For{$ith$ threshold in <$V_{thr}$> from i=1 to n}{
BlankLine
For{j=1 to length < $in_{vec}$>}{
IF{condition}
STATE $out_{vec}$ ~ leftarrow~ $[out_{vec}(i) + 1]$;
else
STATE $$out_{vec}$ ~ leftarrow~ $[out_{vec}(i) + 0]$;
}
text{$All data $leftarrow$ [Data_{1} + Data_{2}]$};
text{Label $All data $ with "1" and "0"};
}
text{Get $out_{vec}$ vector}
caption{Inutp output algorithm}
label{algorithm2}
end{algorithm}
end{document}
Output:
Why if and else conditions not working???
algorithmic
Welcome to TeX.SX! Your MWE does not have adocumentclass
command but, at a guess, your `IF` should beIf
and yourelse
should beElse
and you are missingEndIf
.
– Andrew
yesterday
Oh, I tried but not working!!
– Mohsen Ali
yesterday
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I want to write if-else conditions inside the for-loop in my algorithm using LaTex. The problem that is if-else do not appear in the algorithm and then not working.
Here my LaTex code:
usepackage[pdftex]{graphicx}
%usepackage{float}
usepackage{amsmath}
%usepackage{algorithm}
usepackage{algorithmic}
%usepackage{algorithm2e}
usepackage[ruled,vlined,linesnumbered,noresetcount]{algorithm2e}
begin{document}
begin{algorithm}[H]
DontPrintSemicolon
SetAlgoLined
%KwResult{Write here the result}
SetKwInOut{Input}{Input}SetKwInOut{Output}{Output}
Input{input vector <$in_{vec}$>}
Output{output vector <$out_{vec}$>}
%BlankLine
Put threshold vector <$V_{thr}$>:~
($thr_{1}$,~$thr_{2}$,~$thr_{3}$,~......~,~$thr_{n}$);
For{$ith$ threshold in <$V_{thr}$> from i=1 to n}{
BlankLine
For{j=1 to length < $in_{vec}$>}{
IF{condition}
STATE $out_{vec}$ ~ leftarrow~ $[out_{vec}(i) + 1]$;
else
STATE $$out_{vec}$ ~ leftarrow~ $[out_{vec}(i) + 0]$;
}
text{$All data $leftarrow$ [Data_{1} + Data_{2}]$};
text{Label $All data $ with "1" and "0"};
}
text{Get $out_{vec}$ vector}
caption{Inutp output algorithm}
label{algorithm2}
end{algorithm}
end{document}
Output:
Why if and else conditions not working???
algorithmic
I want to write if-else conditions inside the for-loop in my algorithm using LaTex. The problem that is if-else do not appear in the algorithm and then not working.
Here my LaTex code:
usepackage[pdftex]{graphicx}
%usepackage{float}
usepackage{amsmath}
%usepackage{algorithm}
usepackage{algorithmic}
%usepackage{algorithm2e}
usepackage[ruled,vlined,linesnumbered,noresetcount]{algorithm2e}
begin{document}
begin{algorithm}[H]
DontPrintSemicolon
SetAlgoLined
%KwResult{Write here the result}
SetKwInOut{Input}{Input}SetKwInOut{Output}{Output}
Input{input vector <$in_{vec}$>}
Output{output vector <$out_{vec}$>}
%BlankLine
Put threshold vector <$V_{thr}$>:~
($thr_{1}$,~$thr_{2}$,~$thr_{3}$,~......~,~$thr_{n}$);
For{$ith$ threshold in <$V_{thr}$> from i=1 to n}{
BlankLine
For{j=1 to length < $in_{vec}$>}{
IF{condition}
STATE $out_{vec}$ ~ leftarrow~ $[out_{vec}(i) + 1]$;
else
STATE $$out_{vec}$ ~ leftarrow~ $[out_{vec}(i) + 0]$;
}
text{$All data $leftarrow$ [Data_{1} + Data_{2}]$};
text{Label $All data $ with "1" and "0"};
}
text{Get $out_{vec}$ vector}
caption{Inutp output algorithm}
label{algorithm2}
end{algorithm}
end{document}
Output:
Why if and else conditions not working???
algorithmic
algorithmic
edited yesterday
Andrew
29.3k34178
29.3k34178
asked yesterday
Mohsen Ali
263
263
Welcome to TeX.SX! Your MWE does not have adocumentclass
command but, at a guess, your `IF` should beIf
and yourelse
should beElse
and you are missingEndIf
.
– Andrew
yesterday
Oh, I tried but not working!!
– Mohsen Ali
yesterday
add a comment |
Welcome to TeX.SX! Your MWE does not have adocumentclass
command but, at a guess, your `IF` should beIf
and yourelse
should beElse
and you are missingEndIf
.
– Andrew
yesterday
Oh, I tried but not working!!
– Mohsen Ali
yesterday
Welcome to TeX.SX! Your MWE does not have a
documentclass
command but, at a guess, your `IF` should be If
and your else
should be Else
and you are missing EndIf
.– Andrew
yesterday
Welcome to TeX.SX! Your MWE does not have a
documentclass
command but, at a guess, your `IF` should be If
and your else
should be Else
and you are missing EndIf
.– Andrew
yesterday
Oh, I tried but not working!!
– Mohsen Ali
yesterday
Oh, I tried but not working!!
– Mohsen Ali
yesterday
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f460883%2fif-else-condition-not-working-inside-for-loop-in-latex%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Welcome to TeX.SX! Your MWE does not have a
documentclass
command but, at a guess, your `IF` should beIf
and yourelse
should beElse
and you are missingEndIf
.– Andrew
yesterday
Oh, I tried but not working!!
– Mohsen Ali
yesterday