ozi-rock Posted May 23, 2009 Report Posted May 23, 2009 Hi guys, I'm having trouble figuring out how to read inputs from the arrow keys in matlab. I have a function which control an external board I have controlling a motor. I want to put this function in an if else type code so that if the button is pushed the function powers the board (sets value to 1) else the board return to no power (sets value to zero). I dont need to know how to tell it to go to one or zero just to tell it to use the function I already have when I push the arrow key. Thanks in advance,Oisin Quote
alexander Posted May 26, 2009 Report Posted May 26, 2009 I've never coded in Matlab, but if i'm not mistaken (and people that have done a fair share of matlab code will correct me if i'm wrong), this is done with the use of the input function input(prompt_string, ['s']) where prompt string is the prompt, and 's' is an optional variable signifying to return a string rather then a numeric value example power_state=0; power = input('Power up? (Y/N) [Y]: ', 's'); power = upper(power); switch (power) case 'Y' power_state=1 case 'N' power_state=0 otherwise power_state=1 end As to using arrow keys, as far as i can see there is no way to read continuous input from the keyboard, as i am not sure that Matlab was meant as that kind of a language. You could probably use Python with Matlab to achieve all that, or maybe call C functions to get your the input, but at the moment i can not find a way to read continuous input, i just dont think it was made to be that kind of a language... Quote
ozi-rock Posted May 26, 2009 Author Report Posted May 26, 2009 Ok I had the feeling it might be something like that since I couldnt find how to do it on the net. Thanks for clearing it up a bit anyway. Oisin Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.