Can I only declare a variable NOT define.

조회 수: 1 (최근 30일)
Jeong-Hoon Park
Jeong-Hoon Park 2017년 8월 23일
편집: José-Luis 2017년 8월 23일
When I make a program, I've got a question. In C/C++, before using a variable, should define or at least declare the variable like the following.
int a;
or
int a = 2;
However in MATLAB, Can I just declare a variable? In other words, is
variable;
varid?

채택된 답변

José-Luis
José-Luis 2017년 8월 23일
편집: José-Luis 2017년 8월 23일
No. Different paradigm. Matlab is weakly typed. Double is the default type. Implicit conversions everywhere.
dummy = '3' * 5
Even funnier:
dummy = 'θ' - pi
If you need it to exist before using it (why?), you can declare it to be empty.
a = [];
And go on your merry way.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 시작과 종료에 대해 자세히 알아보기

태그

아직 태그를 입력하지 않았습니다.

Community Treasure Hunt

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

Start Hunting!