Preface The first edition of MATLAB for Behavioral Scientists(published in 2007)was the result eeooeoeoe t write the ng stu ctive neuroscience,economics,a nd s mas much as scientists in other fields.They ohe able t n to do r the nally spe ing of granting agencies to pay other to program for them To give some examples a behavioral scientist-a behavioral economist.say-wishing to model decision making should be able to roll up her sleeves and observed and expected data in the way she prefers.A personality p in designing a new questionnaire requiring a special computer interface should be able to oursue that aim A svchotherapist wanting to model changing relations between mem- bers of a family should be able to characterize that process with custom-made animations that show network links with dynamically changing thicknesses and colors.growing and shrinking over time,if that's what she wants.A cognitive psychologist interested in setting up and conducting behavioral experiments should be able to create any kind of stimuli and response recording capabilities he or she cares to,not being limited by what's possible with off-the-shelf commercial products. This book is meant to help behavioral scientists(and especially students entering this field) to do these things.The authors of this book assume you have no prior familiarity with com- puter programming.and we assume you have no knowledge of mathematics beyond wha ble.our aim is to draw you in and help you feelcom in high sch he text is me at first seem foreign and maybe even scary. y as well a will appen b e.I es a tough hide to b ve you ha d has first but the med has s feel k to program.No one does! Programming needn't be unpleasant.however.The attitude to have is to keep an open mind about the value of mistakes.If you treat errors as windows for improvement,you will learn a lot.Availing yourself of that learning,when you see a program work and especially ixix Preface The first edition of MATLAB for Behavioral Scientists (published in 2007) was the result of a rebellious thought. The prevailing view before then was that most behavioral scientists shouldnÊt or couldnÊt write their own computer programs. This irked the first author, who decided to pursue the notion that all behavioral scientists, including students in the relevant fields (psychology, cognitive and affective neuroscience, economics, and so on), could and should learn to program for themselves. Behavioral scientists need to be able to program as much as scientists in other fields. They need to be able to program to do whatever they want, computationally speaking, without having to rely on the kindness of strangers or the largesse of granting agencies to pay others to program for them. To give some examples, a behavioral scientist·a behavioral economist, say·wishing to model decision making should be able to roll up her sleeves and graph data showing observed and expected data in the way she prefers. A personality psychologist interested in designing a new questionnaire requiring a special computer interface should be able to pursue that aim. A psychotherapist wanting to model changing relations between members of a family should be able to characterize that process with custom-made animations that show network links with dynamically changing thicknesses and colors, growing and shrinking over time, if thatÊs what she wants. A cognitive psychologist interested in setting up and conducting behavioral experiments should be able to create any kind of stimuli and response recording capabilities he or she cares to, not being limited by whatÊs possible with off-the-shelf commercial products. This book is meant to help behavioral scientists (and especially students entering this field) to do these things. The authors of this book assume you have no prior familiarity with computer programming, and we assume you have no knowledge of mathematics beyond what is generally learned in high school. The text is meant to be as friendly and encouraging as possible. Our aim is to draw you in and help you feel comfortable within a domain that may at first seem foreign and maybe even scary. Programming can be humbling. If you set out to learn to program, you should prepare yourself emotionally as well as intellectually for what will happen because you will be dealing with an unfeeling machine. It takes a tough hide to believe you have a program that does what you want, only to discover that the program doesnÊt run, generates unexpected results, or produces outputs that seem reasonable at first but then turn out to be wrong. Everyone who has programmed has gone through this, including the authors of this book, so donÊt feel like you need to be able to program perfectly. No one does! Programming neednÊt be unpleasant, however. The attitude to have is to keep an open mind about the value of mistakes. If you treat errors as windows for improvement, you will learn a lot. Availing yourself of that learning, when you see a program work and especially