Can I only declare a variable NOT define.

1 vue (au cours des 30 derniers jours)
Jeong-Hoon Park
Jeong-Hoon Park le 23 Août 2017
Modifié(e) : José-Luis le 23 Août 2017
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?

Réponse acceptée

José-Luis
José-Luis le 23 Août 2017
Modifié(e) : José-Luis le 23 Août 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.

Plus de réponses (0)

Catégories

En savoir plus sur 시작과 종료 dans Help Center et File Exchange

Tags

Aucun tag saisi pour le moment.

Community Treasure Hunt

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

Start Hunting!