Last active
August 2, 2017 23:34
-
-
Save tarrsalah/79c5826e862c891a8f065fe6f2d48507 to your computer and use it in GitHub Desktop.
Execute a function with arguments from the commande-line
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/octave --silent | |
a = str2num(argv(){1}); | |
b = str2num(argv(){2}); | |
printf("%d\n", a + b); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/octave --silent | |
a = str2num(argv(){1}); | |
b = str2num(argv(){2}); | |
function result = add (a, b) | |
result = a + b; | |
endfunction | |
printf("%d\n", add(a , b)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I run the script by
./add_example.m 23 43
, the result is66
as expected.Make sure that the file
add_example.m
is executable by callingchmod +x ./add_example.m
.