You can create a string with the desired variable names using sprintf
and the loop counter variable, and then use the eval
function to create the variables with those names. Here's an example code:
main.m180 chars6 lines
This code will create 10 variables named myVar1
, myVar2
, ... myVar10
, with values 2
, 4
, ..., 20
, respectively.
gistlibby LogSnag