MATLAB Answers

0

Can I only declare a variable NOT define.

Asked by Jeong-Hoon Park on 23 Aug 2017
Latest activity Edited by José-Luis
on 23 Aug 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?

  0 Comments

Sign in to comment.

Tags

No tags entered yet.

1 Answer

Answer by José-Luis
on 23 Aug 2017
Edited by José-Luis
on 23 Aug 2017
 Accepted Answer

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 Comments

Sign in to comment.