转换的数字数组为二进制数字 [英] Convert array of digits to a binary number

查看:167
本文介绍了转换的数字数组为二进制数字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我怎么能转换的数字数组为二进制数字?例如:

How could I convert array of digits to a binary number? For instance:

a=[1 0 1 0 1 0]

我想转换为二进制数

I would like to convert to a binary number

B = 101010

是否有可能不用循环呢?

Is it possible to do without loops?

推荐答案

也许这是你想要什么:

char(a+'0')

例如:

>> a=[1 0 1 0 1 0]

a =

     1     0     1     0     1     0

>> char(a+'0')

ans =

101010

这工作由每个号码转换成其ASCII code( + 0 ),然后产生数字的向量转换为字符串( CHAR())。

This works by converting each number to its ASCII code (+'0') and then converting the vector of resulting numbers to a string (char()).

这篇关于转换的数字数组为二进制数字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆