You can use the eval function in MATLAB to evaluate the value of a variable whose name is stored as a string. Here is an example:
main.m149 chars10 lines
This code will loop over i values of 1, 2, and 3, and construct the variable names b1, b2, and b3 using sprintf. It will then evaluate the value of the variable with that name using eval, and print out the results using fprintf.
gistlibby LogSnag