Introduction To Matlab Class 5 Instructors: Hristiyan (Chris) Kourtev and Xiaotao Su, PhD.

Slides:



Advertisements
Similar presentations
Introduction to Programming using Matlab Session 2 P DuffourJan 2008.
Advertisements

Matlab Intro Simple introduction to some basic Matlab syntax. Declaration of a variable [ ] Matrices or vectors Some special (useful) syntax. Control statements.
Matlab Class 5 Xiaotao Su, Ph.D. Visual Psychophysicist & IT Group Leader Rutgers Center for Cognitive Science (RuCCS)
Introduction to Matlab
BRIAN D. HAHN AND DANIEL T. VALENTINE THIRD EDITION Essential MATLAB® for Engineers and Scientists.
Lecture (6) Programming (3) Eng. Osama Talaat 1. Announcement  Previous lecture videos are available at the course link.  Extra Materials.  Survey.
Microsoft® Small Basic
Table of Contents II: Customize your TOC Change the appearance of your TOC You’ve created an automatic table of contents, but now you feel like making.
Microsoft ® Office Word 2007 Training Table of Contents II: Customize your TOC [Your company name] presents:
Determining Probability Today we’re going to play a spinner game and make predictions about which color will get picked the most times. Let’s get started!
The Laser-War Game Author: Hongliang Zhang Lambton College
Introduction to Matlab By: Dr. Maher O. EL-Ghossain.
Get number The ginput command creates crosshairs. When the user clicks the x,y values of the crosshairs are returned.
Week 7 - Programming I Relational Operators A > B Logical Operators A | B For Loops for n = 1:10 –commands end.
Introduction to Visual Basic What it is, and a simple program Mike Thelwall University of Wolverhampton, UK.
Microsoft ® Office PowerPoint ® 2003 Training Create your first Presentation Mr Garel…… presents:
January 2011City of Boise 1 City of Boise Time Clock Training Airport Biometrics Clocks.
Chapter 8: String Manipulation
Chapter 3 Working with Symbols and Interactivity.
Visual Basic Games: Week 3 Global variables, parameters, Select, KeyDown Enable, Visible, Focus State of Game Read chapter 3.
Matlab Class 7 Hristiyan Kourtev & Xiaotao Su, Ph.D. Visual Psychophysicist & IT Group Leader Rutgers Center for Cognitive Science (RuCCS)
January 2011City of Boise 1 City of Boise Time Clock Training Timecard Entry (CyberShift) Clocks.
T U T O R I A L  2009 Pearson Education, Inc. All rights reserved Typing Application Introducing Keyboard Events, Menus, Dialogs and the Dictionary.
1 Lab of COMP 406 Teaching Assistant: Pei-Yuan Zhou Contact: Lab 1: 12 Sep., 2014 Introduction of Matlab (I)
Determining Probability Today we’re going to play a spinner game and make predictions about which color will get picked the most times. Let’s get started!
Selection Programming EE 100. Outline introduction Relational and Logical Operators Flow Control Loops Update Processes.
Computational Methods of Scientific Programming Lecturers Thomas A Herring, Room A, Chris Hill, Room ,
CMPS 1371 Introduction to Computing for Engineers CONDITIONAL STATEMENTS.
What does C store? >>A = [1 2 3] >>B = [1 1] >>[C,D]=meshgrid(A,B) c) a) d) b)
Microsoft Office XP Illustrated Introductory, Enhanced Started with Windows 2000 Getting.
Practical Programming COMP153-08S Week 5 Lecture 1: Screen Design Subroutines and Functions.
More on GLUT Programming Glenn G. Chappell U. of Alaska Fairbanks CS 381 Lecture Notes Monday, September 15, 2003.
Lecture 26: Reusable Methods: Enviable Sloth. Creating Function M-files User defined functions are stored as M- files To use them, they must be in the.
Introduction To Matlab Class 9 Instructors: Hristiyan (Chris) Kourtev and Xiaotao Su, PhD.
Introduction To Matlab Class 4 Instructors: Hristiyan (Chris) Kourtev and Xiaotao Su, PhD Double click the matlab icon When prompted click “Skip”
EGR 115 Introduction to Computing for Engineers Designing The Battleship Game in MATLAB Monday 22 Sept 2014 EGR 115 Introduction to Computing for Engineers.
Introduction to Matlab
EGR 115 Introduction to Computing for Engineers MATLAB Basics 6: Debugging in MATLAB Monday 15 Sept 2014 EGR 115 Introduction to Computing for Engineers.
INTRODUCTION TO MATLAB DAVID COOPER SUMMER Course Layout SundayMondayTuesdayWednesdayThursdayFridaySaturday 67 Intro 89 Scripts 1011 Work
Arrays. The array data structure Array is a collection of elements, that have the same data type Integers (int) Floating point numbers (float, double)
In this activity, we are going to type a simple Chinese sentence with Microsoft Word by Tsang-jei Input Method and Simplified Tsang-jei Input Method. 1Start.
Word Create a basic TOC. Course contents Overview: table of contents basics Lesson 1: About tables of contents Lesson 2: Format your table of contents.
Introduction to Matlab Patrice Koehl Department of Biological Sciences National University of Singapore
EGR 115 Introduction to Computing for Engineers Branching & Program Design – Part 3 Friday 03 Oct 2014 EGR 115 Introduction to Computing for Engineers.
EGR 115 Introduction to Computing for Engineers Loops and Vectorization – Part 1 Monday 13 Oct 2014 EGR 115 Introduction to Computing for Engineers.
Matlab Class 4 Xiaotao Su, Ph.D. Visual Psychophysicist & IT Group Leader Rutgers Center for Cognitive Science (RuCCS) and Chris Kourtev.
Click the pictures to advance to next slide Use the left arrow to go back.
Matlab Class 6 Xiaotao Su, Ph.D. Visual Psychophysicist & IT Group Leader Rutgers Center for Cognitive Science (RuCCS) and Chris Kourtev.
MATLAB (Matrix Algebra laboratory), distributed by The MathWorks, is a technical computing environment for high performance numeric computation and.
Matlab Class 8 Xiaotao Su, Ph.D. Visual Psychophysicist & IT Group Leader Rutgers Center for Cognitive Science (RuCCS) and Chris Kourtev.
Introduction to Matlab. Outline:  What is Matlab? Matlab Screen Variables, array, matrix, indexing Operators.
PowerPoint PowerPoint is used for creating slideshows that accompany speeches, lectures, or other types of presentations. Slides can include text, images,
MATLAB – More Script Files
4.0.2 Microsoft Word Screen Components Quiz
Introduction To Matlab Class 3
Introduction to Matlab
Repetition Structures Chapter 9
Last time Cells & Structures Organizing an Experiment
Matlab Class 2 Xiaotao Su, Ph. D
Scripts & Functions Scripts and functions are contained in .m-files
Introduction To Matlab Class 2
Introduction to MATLAB
Introduction To Matlab Class 1
Matlab Class 6 Xiaotao Su, Ph. D
Introduction To Matlab Class 7
مناهــــج البحث العلمي
Introduction To Matlab Class 9
flow charts and system diagrams
‘If’ statements, relational operators, and logical operators
Presentation transcript:

Introduction To Matlab Class 5 Instructors: Hristiyan (Chris) Kourtev and Xiaotao Su, PhD

Optional Presentation Title Unit Name Accurate Timing GetSecs is a psychtoolbox function that provides highly accurate timing. It returns the number of seconds since the machine has started up To test precision on your machine, type: GetSecsTick a = GetSecs GetSecs – a Command Window:

Optional Presentation Title Unit Name KbCheck KbCheck is used to check if a key is being pressed and to find out what key is being pressed. Returns three values [key_press, secs, key_code]=KbCheck

Optional Presentation Title Unit Name KbCheck KbCheck is used to check if a key is being pressed and to find out what key is being pressed. Returns three values [key_press, secs, key_code]=KbCheck 1 or 0 depending on if there was a key press Time that this test took place (This is from GetSecs function) Vector representing all of the input keys. Elements in the vector are set to 1 if pressed or 0 if not

Optional Presentation Title Unit Name Speed Test Game %speed_test.m %tests your reaction time WaitSecs(1); disp('Ready?'); num_sec_to_start = rand*5+1; WaitSecs(num_sec_to_start); too_soon = 0; timer = GetSecs; while ((GetSecs-timer)<num_sec_to_start)... && (~too_soon) [too_soon, secs, keyCode] = KbCheck; if(too_soon) break; end if(too_soon) disp('you pressed the key too early'); else disp('NOW!'); timer = GetSecs; while 1 [key_is_down, secs, key_code] = KbCheck; if(key_is_down) break end elapsed_time = secs - timer; disp(['Your time was ', num2str(elapsed_time)]); end

Optional Presentation Title Unit Name Task 1 Make it so if someone presses a key too early, the program give a message and exits. [key_press, secs, key_code]=KbCheck 1 or 0 depending on if there was a key press Time that this test took place (This is from GetSecs function) Vector representing all of the input keys. Elements in the vector are set to 1 if pressed or 0 if not (Tip:first remove WaitSecs

Optional Presentation Title Unit Name Speed Test Game %speed_test.m %tests your reaction time WaitSecs(1); disp('Ready?'); num_sec_to_start = rand*5+1; WaitSecs(num_sec_to_start); too_soon = 0; timer = GetSecs; while ((GetSecs-timer)<num_sec_to_start)... && (~too_soon) [too_soon, secs, keyCode] = KbCheck; if(too_soon) break; end if(too_soon) disp('you pressed the key too early'); else disp('NOW!'); timer = GetSecs; while 1 [key_is_down, secs, key_code] = KbCheck; if(key_is_down) break end elapsed_time = secs - timer; disp(['Your time was ', num2str(elapsed_time)]); end

Optional Presentation Title Unit Name What key was pressed? The third returned value is a vector representing all the keys with 1’s for pressed keys and zeros for keys that aren’t pressed To find the value of the key, use: key_name = KbName(key_code); This will return a string corresponding to that key_code

Optional Presentation Title Unit Name Simple program to find key mapping names % get_key_name.m %find out what the name of the key is WaitSecs(1); KbWait; [key_is_down, secs, key_code] = KbCheck; name = KbName(key_code); disp(name);

Optional Presentation Title Unit Name KbName works the other way around as well As you have seen: key_name = KbName(key_code); You can also do the following: return_key = KbName(‘return’); esc_key = KbName(‘esc’); up_key = KbName(‘up’); And this will get you the index of the element in the key_code vector that corresponds to that key

Optional Presentation Title Unit Name key_code vector when esc is pressed 00 ….00100….. (1)(2) ….(25)(26)(27)(28)(29)…. key_code vector: Values: Indexes So, key_code(27) is 1 esc’s key code is 27

Optional Presentation Title Unit Name Exit on esc %exit_on_esc.m esc_key = KbName('esc'); i = 0; while 1 i = i+1 [key_is_down, secs, key_code] = KbCheck; if(key_code(esc_key)) break; end disp('Good Bye');

Optional Presentation Title Unit Name Moving Dot %moving_dot.m clear all; screen_setup; up_key = KbName('up'); down_key = KbName('down'); left_key = KbName('left'); right_key = KbName('right'); esc_key = KbName('esc'); shape = [20, 20, 100, 100]; color = [255, 0, 255]; tic while toc<10 Screen(window, 'DrawOval', … color, shape); flip; [key_is_down, secs, key_code] … = KbCheck; if(key_code(esc_key)) break end clear screen;

Optional Presentation Title Unit Name Task 2 Make it so the arrow keys will move the dot