Declare & initialize variables in one line in MATLAB without using an array or vector

a = 0;
b = 0;
c = 0;

Can I do this in one statement without using an array/vecor?

Upvotes: 3

Views: 3510

Answers (1)

macduff
macduff

Reputation: 4685

I would try using the deal function.

http://www.mathworks.com/help/matlab/ref/deal.html

      [a,b,c] = deal(0,0,0);

There are other ways, but this is a good function to learn.

Upvotes: 9

Related Questions