Go Back   Science Forums > Help and Advice > Questions and Answers
Comment
 
LinkBack Question Tools
Published by ozi-rock 05-23-2009
Not Ranked  0 score     
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
  #1 (permalink)  
By alexander on 05-26-2009
Re: How do use arrow keys as inputs in matlab?

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
Code:
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...
Last edited by alexander; 05-26-2009 at 07:19 AM..
Reply With Quote
  #2 (permalink)  
By ozi-rock on 05-26-2009
Re: How do use arrow keys as inputs in matlab?

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
Reply With Quote
Comment

Bookmarks

Currently Active Users Viewing This Question: 1 (0 members and 1 guests)
 
Question Tools


Similar Threads
Question Question Starter Category Comments Last Post
Hi From adam matlab Fan adam0211 Introductions 2 04-29-2009 12:49 AM
Matlab 7.7.0? ThisIsMyName Science Projects and Homework 0 04-21-2009 05:23 PM
'Sneakey' photos could steal your keys Michaelangelica Science News Elsewhere 2 11-22-2008 11:40 PM
Standard map in matlab sanctus Computer Science and Technology 5 05-03-2005 06:03 PM
The arrow of time Aki Physics and Mathematics 9 04-11-2005 01:44 AM

» Advertisement
» Current Poll
Who's the sexiest man alive? Johnny Depp or Robert Pattinson?
Johnny Depp - 27.27%
3 Votes
Robert Pattinson - 0%
0 Votes
Someone else (please specify) - 45.45%
5 Votes
I'm too macho to think a guy is sexy - 27.27%
3 Votes
Total Votes: 11
You may not vote on this poll.


All times are GMT -8. The time now is 11:29 AM.

Hypography?

Hypography [n.]: A combination of "hyperlink" and "bibliography" - ie, a list of links to electronic documents. Comparable to discography and bibliography, but not cartography.

We have been online since May 2000, and aim to be the best place to find and share science-related content of all kinds.

Share the love!

Please add more science to your life. Use our RSS feeds on your blog, your portal, or your favorite feedreader!


Powered by vBulletin® Version 3.8.3
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.2
Copyright © 2000-2009 Hypography
Part of the Hypography - Science for Everyone Network
Powered by GARS © 2005-2008