Clear Filters
Clear Filters

Can I only declare a variable NOT define.

1 view (last 30 days)
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;
int a = 2;
However in MATLAB, Can I just declare a variable? In other words, is

Accepted Answer

José-Luis on 23 Aug 2017
Edited: José-Luis on 23 Aug 2017
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.

More Answers (0)


Find more on 시작과 종료 in Help Center and File Exchange


No tags entered yet.

Community Treasure Hunt

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

Start Hunting!