how to assign variables from a list to multiple variables in one line in matlab

You can assign variables from a list to multiple variables in one line using bracket notation. Here is an example:

main.m
>> list = [1, 2, 3];
>> [a, b, c] = list

a =

     1

b =

     2

c =

     3
80 chars
15 lines

In the example above, we created a list of numbers [1, 2, 3] and then assigned them to individual variables a, b, and c in one line using the bracket notation [a, b, c] = list.

related categories

gistlibby LogSnag