MATLAB for Behavioral Scientists
David A. Rosenbaum, Jonathan Vaughan, Brad Wyble
- 400 pages
- English
- ePUB (mobile friendly)
- Available on iOS & Android
MATLAB for Behavioral Scientists
David A. Rosenbaum, Jonathan Vaughan, Brad Wyble
About This Book
Written specifically for those with no prior programming experience and minimal quantitative training, this accessible text walks behavioral science students and researchers through the process of programming using MATLAB. The book explores examples, terms, and programming needs relevant to those in the behavioral sciences and helps readers perform virtually any computational function in solving their research problems. Principles are illustrated with usable code. Each chapter opens with a list of objectives followed by new commands required to accomplish those goals. These objectives also serve as a reference to help readers easily relocate a section of interest. Sample code and output and chapter problems demonstrate how to write a program and explore a model so readers can see the results obtained using different equations and values. A web site provides solutions to selected problems and the book's program code output and examples so readers can manipulate them as needed. The outputs on the website have color, motion, and sound.
Highlights of the new edition include:
â˘Updated to reflect changes in the most recent version of MATLAB, including special tricks and new functions.
â˘More information on debugging and common errors and more basic problems in the rudiments of MATLAB to help novice users get up and running more quickly.
â˘A new chapter on Psychtoolbox, a suite of programs specifically geared to behavioral science research.
â˘A new chapter on Graphical User Interfaces (GUIs) for user-friendly communication.
â˘Increased emphasis on pre-allocation of memory, recursion, handles, and matrix algebra operators.
The book opens with an overview of what is to come and tips on how to write clear programs followed by pointers for interacting with MATLAB, including its commands and how to read error messages. The matrices chapter reviews how to store and access data. Chapter 4 examines how to carry out calculations followed by a review of how to perform various actions depending on the conditions. The chapter on input and output demonstrates how to design programs to create dialogs with users (e.g., participants in studies) and read and write data to and from external files. Chapter 7 reviews the data types available in MATLAB. Readers learn how to write a program as a stand-alone module in Chapter 8. In Chapters 9 and 10 readers learn how to create line and bar graphs or reshape images. Readers learn how to create animations and sounds in Chapter 11. The book concludes with tips on how to use MATLAB with applications such as GUIs and Psychtoolbox.
Intended as a primary text for Matlab courses for advanced undergraduate and/or graduate students in experimental and cognitive psychology and/or neuroscience as well as a supplementary text for labs in data (statistical) analysis, research methods, and computational modeling (programming), the book also appeals to individual researchers in these disciplines who wish to get up and running in MATLAB.
Frequently asked questions
Information
1.
Introduction
1.1 Getting Oriented
1.2 Getting an Overview of This Book
- Introduction. By reading the present chapter, you will learn more than you may already know about how computers work and what computer programming languages do. You will also learn about the ways you should approach computer programming. Finally, by reading this chapter, you will understand how this book is organized. That information can help you use the book efficiently.
- Interacting With MATLAB. By delving into the second chapter, you will learn how to activate MATLABâs windows in order to open, edit, save, and run MATLAB programs.
- Matrices. By studying the third chapter, you will learn how MATLAB enables you to store and access data. Briefly, MATLAB lets you store data in matrices consisting of one or more rows and one or more columns. Matrices are so fundamental to MATLAB that the name of the language is actually short for âMatrix Laboratory.â You can think of a two-dimensional matrix (one having both rows and columns) as analogous to the rows and columns in a spreadsheet.
- Calculations. Computers are good at calculating. Chapter 4 shows how to get your computer to carry out calculations with MATLAB.
- Contingencies. One of the main purposes of a computer program is to perform different actions depending on existing conditions. The logic of a program involves not only calculations but also decision making, such as evaluating variables differently (or not evaluating them at all), depending on their values.
- Input-Output. Chapter 6 shows you how to control your computerâs interactions with the external world. By studying Chapter 6, you will be able to design programs that let you create dialogs with users, including participants in behavioral studies, and to read and write data to and from external files.
- Data Types. One of the biggest challenges in using computers in research is determining how best to represent the data you are working with. It is important to understand what data types are available in MATLAB so you can choose and manipulate your data types accordingly.
- Modules and Functions. Simple programs are usually easy to understand, but when they become more complex it often helps to deal with them in chunks. Some higher level structure is often helpful. Chapter 8 shows you how to write programs that have this property. Those programs often have stand-alone modules and functions. Such modules and functions can be called by a variety of programs. Using modules and functions can help you approach programming from a top-down rather than a bottom-up perspective. Modules and functions can also facilitate the reuse of programs in the future.
- Plots. The ability to generate and manipulate complex graphics for the exploration and presentation of data is widely regarded as one of the special strengths of MATLAB. Chapter 9 exposes you to those strengths by showing you how to make line graphs, bar graphs, and other types of graphs that are suitable for professional presentations and publications.
- Lines, Shapes, and Images. Here you will learn how to create, import, or reshape lines, shapes, and other images that can either stand alone or be included in graphs. Chapter 10 will also show you how to generate three-dimensional graphs.
- Animation and Sound. Chapter 11 builds on the static graphics of the tenth chapter to manipulate figures using simple animation techniques, generate movies, and generate auditory stimuli.
- Enhanced User Interaction. When you think of a typical computer application, what comes to mind is how the program interacts with the user, typically through graphics, the keyboard, the mouse, or touchscreen. Chapter 12 introduces you to some of the tools available in MATLAB for user interactions.
- Psychtoolbox. For real-time work, there are some features that MATLAB ordinarily lacks that are needed for precise and flexible stimulus presentation and data acquisition. Chapter 13 describes a sophisticated extension to MATLAB, Psychtoolbox, which adds features to facilitate research using MATLAB, especially in vision research. This chapter also touches on related packages of interest to behavioral scientists in related areas.
- Debugging. Programs often have bugs because, for better or worse, programming is often a trial-and-error process. While it is hard to know in advance how to address every possible bug, it is possible, based on the authorsâ many goofs of their own, to convey advice about debugging techniques which you may find useful. These are offered in Chapter 13 ⌠oops, Chapter 14 (
- Going On. Chapter 15, the last chapter of the book, provides pointers for going further with MATLAB. This chapter also directs you to other resources you may want to draw on.