0

I have this matlab code and i want to write it's pseudo code in latex, how can i convey the same message as this code. The code is given below

   for i=1:32
   if(1<=i&&i<=16)

    z=circshift(b,mod(i,8),2);

    c=bitxor(bitor(bitand(a,b),c),d);
    c=sprintf('%d',c);

T=dec2bin(mod(bin2dec(z)+ bin2dec(sprintf('%d',bitxor(bitand(bitxor(bitand(a,b),c),d),e)))+bin2dec(c)+bin2dec(W(i,:)),256),8);
e=d;
d=c;
c=circshift(c,5,2);
b=a;
a=T;
  • 2
    Welcome to TeX.SX! I think this is a job for listings or minted. – egreg Feb 16 '18 at 12:20
1

You can use the package matlab-prettifier:

\documentclass{article}
\usepackage{matlab-prettifier}

\begin{document}
\begin{lstlisting}[style=Matlab-editor]
   for i=1:32
   if(1<=i&&i<=16)

    z=circshift(b,mod(i,8),2);

    c=bitxor(bitor(bitand(a,b),c),d);
    c=sprintf('%d',c);

T=dec2bin(mod(bin2dec(z)+ bin2dec(sprintf('%d',bitxor(bitand(bitxor(bitand(a,b),c),d),e)))+bin2dec(c)+bin2dec(W(i,:)),256),8);
e=d;
d=c;
c=circshift(c,5,2);
b=a;
a=T;
\end{lstlisting}
\end{document}

enter image description here

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.