Is there a method to add a default value for input? (in Octave ) Sounds so simple but I can't find it. I just want to give the user a possibility to pres ENTER if the default value is ok, or to change it and then ENTER.
You can try something like this:
function val = get_response(default="Y")
val = input("Your choice? [Y]/N ", "s");
if isempty(val)
val = default;
endif
endfunction
I wrapped this into a function but you can use the enclosed code directly, of course.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With