【问题标题】:How to convert positive integer to binary representation in the form of a string? Matlab [duplicate]如何以字符串的形式将正整数转换为二进制表示? Matlab [重复]
【发布时间】:2017-02-20 16:22:32
【问题描述】:

到目前为止,我有 Bin=zeros(10,1);

Bin(1,1)=1;
Bin(2,1)=2;
c=ones(1,10);


for (i=3:10)
    Bin(i)=Bin(i-1)*2;
end
P=Bin

for (i=1:10)
    if (N<=Bin(i,1))
    c(i)=0;
    end

end

它采用整数并使所有二进制数字大于 N 0。但我不知道之后该怎么做。任何帮助将非常感激!我对此比较陌生

【问题讨论】:

    标签: matlab binary integer


    【解决方案1】:

    调用dec2bin(x),其中x 是您的整数。这将返回您想要的字符串。应该内置到 Matlab 中。

    【讨论】:

    • 谢谢你。你知道没有 dec2bin(x) 函数我该怎么做吗?
    猜你喜欢
    • 2022-01-20
    • 2021-02-12
    • 2011-03-27
    • 1970-01-01
    • 2012-08-16
    • 2015-04-23
    • 1970-01-01
    • 2015-12-28
    • 1970-01-01
    相关资源
    最近更新 更多