#!/usr/bin/octave -qf % Copyright 2005 Daniel Cer (daniel.cer@cs.colorado.edu) % % This work is licensed under the Creative Commons Attribution-NonCommercial- % ShareAlike License. To view a copy of this license, visit % http://creativecommons.org/licenses/by-nc-sa/2.5/ or send a letter to % Creative Commons, 543 Howard Street, 5th Floor, San Francisco, California, % 94105, USA. if length(argv) != 2 fprintf(stderr, "Usage:\n\t%s [int/real] (count)\n", program_name); exit(-1); endif type = argv{1}; count = str2num(argv{2}); if count <= 0 || round(count) != count fprintf(stderr, "Error: count should be an integer > 0\n"); exit(-2); endif if strcmp(type, "int") for r=floor(rand(count,1)*2**31-1), disp(r); endfor elseif strcmp(type, "real") for r=rand(count,1), disp(r); endfor else fprintf(stderr, "Invalid type: \"%s\"\n", type); exit(-3); endif