在Matlab上需要帮助 [英] need help with matlab

查看:125
本文介绍了在Matlab上需要帮助的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在Matlab中进行编码的帮助,以及如何对二进制代码进行编码.我不知道该如何真正地开始,所以,如果有人可以解释如何做,请在编码中非常有帮助,

十进制二进制
0 000
1 001
2 010
3 011
4 100
5 101
6110
7111

[修订版2更改了拼写,并更正了十进制数字的二进制表示形式; daveauld]

I need help with coding in matlab, how to code binary. I have no idea how to start really, So please, if anyone can explain how to do it, in coding that will be very helpful,

Decimal binary
0 000
1 001
2 010
3 011
4 100
5 101
6 110
7 111

[Revision2 changed spelling, and corrected binary representation of decimal numbers; daveauld]

推荐答案

您在这里:
Here you go:
clear
clc
num=input(''Enter a  positive number: '');
num2=num;
while (num<0)
   clc
   fprintf(''Invalid entry!\n'');
   a=input(''Enter a positive number: '');
end
a=1;
c=num;
d='''';
while (c>=1)
   b=rem(c,2);
   c=c/2;
   c=floor(c);
   d=[d char((b)+''0'')];
   %a=a*10;
end
lsb=rem(num,2);
msb=b;
   
fprintf(''\n\n%g is written %s in binary form.\n\n'',num2,d)
fprintf(''The least-significant bit is %g\n\n'',lsb)
fprintf(''The most-significant bit is %g\n\n'',msb)


非常感谢:)您非常有帮助
thank you very much :) you were very helpful


这篇关于在Matlab上需要帮助的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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