Search Contact information
University of Cambridge Home Department of Engineering
University of Cambridge >  Engineering Department >  computing help
next up previous contents
Next: Vectorising Up: Miscellaneous Previous: Stopping

Program-generated names and commands

This shows how to generate variable names 'on the fly'. This is especially useful when you're running batch jobs and want to save results into several files.
% A1, A2, A3, and A4 are created and set to 3
for i=1:4
s=sprintf('A%d= 3',i);

% This shows how to run a command that's stored in a string
str=input('Type in a command ','s') 

© Cambridge University Engineering Dept
Information provided by Tim Love