So I am wanting to accept command line arguments and the "octave -help" didn't really show me what I wanted. So like many other languages you can use argv to collect command line, here is an example.
Suppose I want to create a test.m file that will accept 4 command line inputs like so:
octave test.m 1 2 3 4
To do that I would do:
%Accept standard in
n1 = str2num(argv(){1})
n2 = str2num(argv(){2})
n3 = str2num(argv(){3})
n4 = str2num(argv(){4})
t=n1+n2+n3+n4; %Do calculations
printf("%d\n", t) %Print standard out...
That way I can do what I wanted.
Saturday, February 1, 2014
Subscribe to:
Posts (Atom)