What is difference between
a=10101010
b= 1 0 1 0 1 0 1 0
when length(a) and length(b) both equal to 8 kindly tell me what is the difference between these two and is there any way to convert a into b or b into a?

답변 (2개)

Azzi Abdelmalek
Azzi Abdelmalek 2014년 2월 23일
편집: Azzi Abdelmalek 2014년 2월 23일

0 개 추천

a=123 % a is a number
b=num2str(a) % b is a string
a=str2num(b) % to get back a
For your case
c='0101' % c is a string
% If you want to get a vector [0 1 0 1] use
c-'0'

댓글 수: 3

Raza Ali
Raza Ali 2014년 2월 23일
its not working,
a=10101010 is not a number its binary value
Azzi Abdelmalek
Azzi Abdelmalek 2014년 2월 23일
편집: Azzi Abdelmalek 2014년 2월 23일
a=10101010 % is not considered as a binary number by Matlab
If you want to represent a binary number, use a string
a='10101010'
another way to represent a binary number is a vector
a=[1 0 1 0 1 0 1 0]
Image Analyst
Image Analyst 2014년 2월 23일
Raza we went over all this already in your original question.

댓글을 달려면 로그인하십시오.

Image Analyst
Image Analyst 2014년 2월 23일

0 개 추천

That's ambiguous code. The first line is okay - a is an integer with value 10,101,010 - but the second is not MATLAB code. You can do
whos a
class(a)
to learn a lot about the variables.

카테고리

도움말 센터File Exchange에서 Operators and Elementary Operations에 대해 자세히 알아보기

질문:

2014년 2월 23일

댓글:

2014년 2월 23일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by