The "<" symbol in DOS and UNIX redirects input from the command line to a file. With the "<" symbol, if you have an executable called "prog" that expects several inputs from the user, you can put all these inputs on separate lines in a text file and have the computer get the inputs from the text file rather than the keyboard. Is there is a similar symbol in MATLAB?
Following is the "prog.m" code:
function progx=input('x=');y=input('y=');z=input('z=');disp(sprintf('x=%e y=%e z=%e',x,y,z));
Following are the actual MATLAB command lines and outputs where the user has to enter the 30, 45, 60 values:
>> prog x=30 y=45 z=60 x=3.000000e+001 y=4.500000e+001 z=6.000000e+001
Following are the MATLAB command lines I envision where the user only has to type the "prog < progins.txt" line below and not the 30, 45, 60 that appear after it:
>> prog < progins.txt x=30 y=45 z=60 x=3.000000e+001 y=4.500000e+001 z=6.000000e+001
Following are the contents of "progins.txt":
30 45 60
Using the "<" symbol would let me automate certain functions that were designed to accept user input. I wouldn't need to make separate code for the user input way versus the automated way. I would have the computer emulate a human user by using the "<" symbol.
The UNIX or DOS ">" feature would also be useful. The ">" feature lets you redirect text output from the command window into a text file. Then you could do things like below in MATLAB:
>> prog < progins.txt > progouts.txt
progouts.txt would then contain:
x=30 y=45 z=60 x=3.000000e+001 y=4.500000e+001 z=6.000000e+001
Best Answer