Click here to Skip to main content
15,895,709 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi to all.

I want to convert a binary vector to equivalent char. for example 01110100 to 't'.
how can i do this in matlab.

thanks.
Posted

1 solution

vect = [0 1 1 1 0 1 0 0];
code = 0;
for i = 1:8
  if (vect(i) > 0)
    code += 2^(8-i);
  end
end
theChar = char(code)

OR
char(sum(vect.*(2.^[7:-1:0])))
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900