Exercises 19 2.Create in MATLAB the following variables: Mathematical expression Solutions (to type after prompt>>followed by Enter) 「34.5687 Mat1=【3.4.56.8 7;12,2,1,3: Mat1-12213 p1,34,2,3]: π3423 [100 Mat2=[1,0,0:0,0,0:0,0,0: 0,0,31: 000 Mat2 000 003 Mat3= 「24681012141 36912151821 Nat3=2:2:14: Mat3(2,:)=3:3:21: e second and the third elements of the third row of b is a variable containing the first and second elements of the second row of Mat3. -Create a matrix called bbcc with b on top of c. Use the first column of Matl and the transpose of the last row of Mat2 to cre- ate a new matrix called nice.Multiply the result by the third element in the first row of Mat3. SubMatl is a matrix obtained from the second and fourth columns of Mat3. n the s of Mat3. NewMat and SubMat2 in the second two columns. Solutions: To type after prompt>followed by Enter Display by MATLAB at1《1,23) 4.5600 8.0000 =Mat1(1,【2,3]) =Mat3(2,1:2) 36 REsuLT=(b+c)*4 RESuLT 30.2400 56.0000 bbec-[bic] bbcc ice=[Mat1(:,1),(Mat2(4,:))‘]*at3(1,3) 18.0000 72.0000 18.8496 18.0000 (continued)
Exercises 19 2. Create in MATLAB the following variables: Mathematical expression Solutions (to type after prompt >> followed by Enter) ⎡ ⎤ ⎢ ⎥ ⎣ ⎦ 3 4.56 8 7 1 = 12 2 1 3 p 34 2 3 Mat Mat1=[3, 4.56, 8, 7; 12, 2, 1, 3; pi, 34, 2, 3]; ⎡ ⎤ ⎢ ⎥ ⎢ ⎥ ⎢ ⎥ ⎢ ⎥ ⎣ ⎦ 100 000 2 = 000 003 Mat Mat2=[1, 0, 0; 0, 0, 0; 0, 0, 0; 0, 0, 3]; or Mat2=1; Mat2(4,3)=3; ⎡ ⎤ = ⎢ ⎥ ⎣ ⎦ 2 4 6 8 10 12 14 3 3 6 9 12 15 18 21 Mat Mat3=[2,4,6,8,10,12,14; 3,6,9,12,15,18,21]; or Mat3=2:2:14; Mat3(2,:)=3:3:21; 3. c is a variable containing the second and the third elements of the third row of Mat1. – b is a variable containing the fi rst and second elements of the second row of Mat3. – Create a matrix called bbcc with b on top of c. – Use the fi rst column of Mat1 and the transpose of the last row of Mat2 to create a new matrix called nice. Multiply the result by the third element in the fi rst row of Mat3. – SubMat1 is a matrix obtained from the second and fourth columns of Mat3. – SubMat2 is a matrix obtained from the fi rst and last columns of Mat3. – NewMat is a 2x4 matrix obtained by using SubMat1 in the fi rst two columns, and SubMat2 in the second two columns. Solutions: To type after prompt >> followed by Enter Display by MATLAB c=Mat1(1,2:3) or c=Mat1(1,[2,3]) c = 4.5600 8.0000 b=Mat3(2,1:2) b = 3 6 REsuLT=(b+c)*4 REsuLT = 30.2400 56.0000 bbcc=[b;c] bbcc = 3.0000 6.0000 4.5600 8.0000 nice=[Mat1(:,1), (Mat2(4,:))’]*Mat3(1,3) nice = 18.0000 0 72.0000 0 18.8496 18.0000 (continued)
20 I Basic Operations (continued) To type after prompt>>followed by Enter Display by MATLAB SubMat1=wat3(:,【2,4]) 612 Try by yourself 14 321 Try by yourself 8214 6 12321 Mol obtained from element-by-element multiplication between SubMatl and SubMat2. -Change the element in position (2,2)of Mol to 5; To type after promptfollowed by Enter Display by MATLAB RESuLT■(b+C)*4 924056.000 Mol=SubMat1.*SubMat2 Mol PAY ATTENTION:MATLAB can also comp the product Mol=SubMat1*SubMat2.However, that is not the element-by-element product Mo1(2,2)=5 Mol A Brick for an Experiment In this section of the book we illustrate.step by step.a MATLAB program imple menting a behavioral experin nent together ith theg are imple (1997).The effect showed by these authors is one of the most compelling examples of interaction between audition and vision.It can be observed by comparing the post coincidence trajectories of two moving objects.The objects are perceived as bounc- ing off each other or as streaming through each other according to whether a sound is presented(or not)when the objects overlap during the motion(Sekuler et al.1997: Watanabe and Shimojo 2001:Remiin et al.2004:Kawabe and Miura 2006:Kawachi and Gyob ba 2006 Zhouet al 2007.C assi and Casco 2009,2010:Grove and Sakurai 2009 The on a m originally propo (134).Metger's display shows wo identical objects .wod ses)that move along the azimuth with uniform rectilinear motion and opposite directions:discs start their motion,overlap and stop at the other disc's starting point with uniform
20 1 Basic Operations To type after prompt >> followed by Enter Display by MATLAB SubMat1=Mat3(:,[2,4]) SubMat1 = 4 8 6 12 Try by yourself SubMat1 = 2 14 3 21 Try by yourself NewMat = 4 8 2 14 6 12 3 21 4. Calculate the sum of b and c and multiply the result by 4. Put the result in the matrix REsuLT. – Create a matrix Mol obtained from element-by-element multiplication between SubMat1 and SubMat2. – Change the element in position (2,2) of Mol to 5; To type after prompt >> followed by Enter Display by MATLAB REsuLT=(b+c)*4 REsuLT = 30.2400 56.0000 Mol=SubMat1.*SubMat2 Mol = 8 112 18 252 PAY ATTENTION: MATLAB can also compute the product Mol = SubMat1*SubMat2. However, that is not the element-by-element product Mol(2,2) = 5 Mol = 8 112 18 5 A Brick for an Experiment In this section of the book we illustrate, step by step, a MATLAB program implementing a behavioral experiment together with the graphical interface for running the program and the statistical analysis for analyzing the data. The experiment we are implementing is a classic experiment in audiovisual perception by Sekuler et al. ( 1997 ) . The effect showed by these authors is one of the most compelling examples of interaction between audition and vision. It can be observed by comparing the post coincidence trajectories of two moving objects. The objects are perceived as bouncing off each other or as streaming through each other according to whether a sound is presented (or not) when the objects overlap during the motion (Sekuler et al. 1997 ; Watanabe and Shimojo 2001 ; Remijn et al. 2004 ; Kawabe and Miura 2006 ; Kawachi and Gyoba 2006 ; Zhou et al. 2007 ; Grassi and Casco 2009, 2010 ; Grove and Sakurai 2009 ) . The effect is based on a motion display originally proposed by Metzger ( 1934 ) . Metzger’s display shows two identical objects (e.g., two discs) that move along the azimuth with uniform rectilinear motion and opposite directions: discs start their motion, overlap and stop at the other disc’s starting point with uniform (continued)
A Brick for an Experiment. 2 optic two different events in the real three-dimensional world.In both events the two objects are placed at different depths so that the retinal images of both have identical size.In one event,the objects start their motion,overlap (i.e.,one object occludes the other).then stream past one another.In the other possible event,in contrast,after the occlusion,the objects reverse their motion and return to their original starting posi- tions.In brief,the motion of the discs is bistable because both the streaming and ncing p rcep ible with the oximal stim ever,the ssilent,whereast e bou ing is pred the sound is presented.We strongly suggest that the reade read the cited paper to have a clearer idea about the experiment we are going to implement in the "brick section. Here,we implement the original experiment by Sekuler et al.(1997).The experi- ment is a 2(motion type)by 2(sound condition)experiment.In the experiment,a disc's motion can be continuous,or it can stop for a certain number of frames when the discs overlap.In addition.the discs'motion rief sou can be accompanied (or not)bya and that is sented when the discs overlap.The subiect's task is to hether s/he per ceived the discs as strea bouncing.Usually.in this type of experiment,the experimenter records the proportion of bounce responses as a function of the various experimental conditions(the number of streaming responses is,of course,the reciprocal of the number of bounce responses). The experiment by Sekuler et al.(1997)is a classic"fixed stimuli"experiment In other words,we know before the subject participates in the experiment what and how many stimuli we are going to pre nt!This is an advantas e,because we can prepare many things in ad tablei.atable in whi a wi g to do in such cases is t Kact exp we are going to presen pentalcoy all events be represented in numbers In this chapter we limit ourselves to writing few variables that will turn out to be useful later.First of all,let's write one variable containing the two factors we are manipulating in the experiment.We will symbolize each factor/condition in numbers. >conditions=[1,1;1,2;2,1;2,2] if you visualize the content of this variable,it looks like this >conditions conditions 1 1 2 2 This is no tthe case of adaptive cedures in which the stimuli presented are nse
A Brick for an Experiment. 21 rectilinear motion. This simple two-dimensional display is a complex inverse optics problem for the visual system (Marr 1982 ) . The display is equally representative of two different events in the real three-dimensional world. In both events the two objects are placed at different depths so that the retinal images of both have identical size. In one event, the objects start their motion, overlap (i.e., one object occludes the other), then stream past one another. In the other possible event, in contrast, after the occlusion, the objects reverse their motion and return to their original starting positions. In brief, the motion of the discs is bistable because both the streaming and bouncing percepts are compatible with the proximal stimulus. However, the streaming percept is usually predominant if the motion display is silent, whereas the bouncing is predominant when the sound is presented. We strongly suggest that the reader read the cited paper to have a clearer idea about the experiment we are going to implement in the “brick” section. Here, we implement the original experiment by Sekuler et al. ( 1997 ) . The experiment is a 2 (motion type) by 2 (sound condition) experiment. In the experiment, a disc’s motion can be continuous, or it can stop for a certain number of frames when the discs overlap. In addition, the discs’ motion can be accompanied (or not) by a brief sound that is presented when the discs overlap. The subject’s task is to report whether s/he perceived the discs as streaming or as bouncing. Usually, in this type of experiment, the experimenter records the proportion of bounce responses as a function of the various experimental conditions (the number of streaming responses is, of course, the reciprocal of the number of bounce responses). The experiment by Sekuler et al. ( 1997 ) is a classic “fi xed stimuli” experiment. In other words, we know before the subject participates in the experiment what and how many stimuli we are going to present. 1 This is an advantage, because we can prepare many things in advance. For example, a wise thing to do in such cases is to write an event table, i.e., a table in which we write the exact experimental condition we are going to present to the subject trial after trial. In the event table all events will be represented in numbers. In this chapter we limit ourselves to writing few variables that will turn out to be useful later. First of all, let’s write one variable containing the two factors we are manipulating in the experiment. We will symbolize each factor/condition in numbers. >> conditions = [1, 1; 1, 2; 2, 1; 2, 2]; if you visualize the content of this variable, it looks like this: >> conditions conditions = 1 1 1 2 2 1 2 2 1 This is not the case of adaptive psychophysical procedures in which the stimuli presented are selected trial by trial as a function of the subject’s response
22 I Basic Operation The left column codes as a number the video display we are presenting (e.g. 1=continuous motion:2=discontinuous motion).the right column codes as a num her the sound a ociated with the display (1=no sound:2=sound).Howe Iexperim i are preser ore tha once,they with acertain number of repstitions (say.20 tmes cach). are presente >repetitions 20; we can now begin to write the event table: >>EventTable=【]: >>EventTable[EventTable;conditions); >EventTable-【E ent Table >EventTable-[EventTable;conditions]i You should repeat the command EventTable=[EventTable; condi- tions];20 times (i.e.,the number of repetitions)in order to obtain the complete event table.In a later chapter we will show how to generate repetitive commands automatically. Now let's add to the left of the EventTable a new column with the trial number (note the use of the apostrophe,which transposes the array we are creating,so that Table bec matrix of a few columns but several rows,one row for each trial of the experiment): >TotalNumberofTrials length(EventTable(:,1)); >TrialNumber=(1:TotalNumberofTrials)'; >EventTable -[TrialNumber,EventTable]; Now let's look at the content of the table matrix.At trial number 12,for example we know that we are going to present the display 2 (the discontinuous motion together with the sound (i.e.,2).At trial number 37,we will present the display (the continuous motion)and no sound (i.e.1).and so on.How ever.in the ent nts in psychol gy,we ant the stimuli ck of tris th ubject perfor way,we avoid for example,a fixed sequence of trials.We can do this by shuffling the trial sequence by means of randperm.which is a MATLAB function that generates a random permutation of integers from I to n,i.e.the input the user has to pass to the func tion.(Note that we will transpose the output of the randperm function so that we have an array with one column and several rows.)Now we substitute the trial >RandomTrialSequence-randperm(TotalNumberofTrials)'; >EventTable(:,1)=RandomTrialSequence; Now let's sort the EventTable content by the shuffled trial number in the first column: >EventTable sortrows (EventTable,1):
22 1 Basic Operations The left column codes as a number the video display we are presenting (e.g., 1 = continuous motion; 2 = discontinuous motion), the right column codes as a number the sound associated with the display (1 = no sound; 2 = sound). However, usually in psychological experiments stimuli are presented more than once, i.e., they are presented with a certain number of repetitions (say, 20 times each). >> repetitions = 20; we can now begin to write the event table: >> EventTable = []; >> EventTable = [EventTable; conditions]; >> EventTable = [EventTable; conditions]; >> EventTable = [EventTable; conditions]; You should repeat the command EventTable = [EventTable; conditions]; 20 times (i.e., the number of repetitions) in order to obtain the complete event table. In a later chapter we will show how to generate repetitive commands automatically. Now let’s add to the left of the EventTable a new column with the trial number (note the use of the apostrophe , which transposes the array we are creating, so that EventTable becomes a matrix of a few columns but several rows, one row for each trial of the experiment): >> TotalNumberOfTrials = length(EventTable(:, 1)); >> TrialNumber = (1:TotalNumberOfTrials)’; >> EventTable = [TrialNumber, EventTable]; Now let’s look at the content of the table matrix. At trial number 12, for example, we know that we are going to present the display 2 (the discontinuous motion) together with the sound (i.e., 2). At trial number 37, we will present the display 1 (the continuous motion) and no sound (i.e., 1), and so on. However, in the current experiment, as in the majority of experiments in psychology, we want the stimuli to be randomized within the block of trials the subject performs. In this way, we avoid possible unwanted effects such as the serial effects that could arise if we were using, for example, a fi xed sequence of trials. We can do this by shuffl ing the trial sequence by means of randperm , which is a MATLAB function that generates a random permutation of integers from 1 to n, i.e., the input the user has to pass to the function. (Note that we will transpose the output of the randperm function so that we have an array with one column and several rows.) Now we substitute the trial sequence column by the shuffl ed trial sequence column: >> RandomTrialSequence = randperm(TotalNumberOfTrials)’; >> EventTable(:, 1) = RandomTrialSequence; Now let’s sort the EventTable content by the shuffl ed trial number in the fi rst column: >> EventTable = sortrows(EventTable, 1);
Suggested Readings 23 If you now echo in the ommand window tTable matrix you will see that the stimuli presentation list is now nicely randomized A part of the commands we have shown will be included in a script that automati- cally generates the event table in the desired form.This will be shown in Chap.3. References edoes not explain Grassi M.Casco C(2010)A udiovisual bo nct:when sound cone affects K2009 motion reversal is reduced.Perception 38:951-965 e perception persists as the probability of a Kawabe T.Miura K (2006)Effects of the orientation of moving objects on the perception of Kaw by moving object alters stream/bounce event r ion Percention 35-1289-1294 Marr D(9)Vision:a computational investigation into the human representation and processing W(193 o W.H.Free ew York ion of the"stream- R menon.J Physiol Anthropol Appl Human Sci 23:243-247 .(1997)S0 on Psvchol Sci 12:109-116 Zhou F.Wong V.Sekuler R(2007)Multi-sensory integration of spatio-t es:one plus one does not aways equal two.Exp Brain Res 1 segmentar Suggested Readings Some of the concepts illustrated in this chapter can be found,in an extended way,in the following books: Gilat A (2008)MATIAB- Mahwah NI Hunt BR Lins aman RL et al (2006)A guide to MATLAB:for beginners and experienced users. 2nd edn.Cambridge University Press,Cambridge,United Kingdom Rosenbaum DA (2007)MATLAB for behavioral scientists.Lawrence Erlbaum Associates Hoboken.NJ
Suggested Readings 23 If you now echo in the command window the content of the EventTable matrix, you will see that the stimuli presentation list is now nicely randomized. A part of the commands we have shown will be included in a script that automatically generates the event table in the desired form. This will be shown in Chap. 3 . References Grassi M, Casco C (2009) Audiovisual bounce-inducing effect: attention alone does not explain why the discs are bouncing. J Exp Psychol Hum Percept Perform 35:235–243 Grassi M, Casco C (2010) Audiovisual bounce-inducing effect: when sound congruence affects grouping in vision. Atten Percept Psychophys 72:378–386 Grove PM, Sakurai K (2009) Auditory induced bounce perception persists as the probability of a motion reversal is reduced. Perception 38:951–965 Kawabe T, Miura K (2006) Effects of the orientation of moving objects on the perception of streaming/bouncing motion display. Percept Psychophys 68:750–758 Kawachi Y, Gyoba J (2006) Presentation of a visual nearby moving object alters stream/bounce event perception. Perception 35:1289–1294 Marr D (1982) Vision: a computational investigation into the human representation and processing of visual information. W. H. Freeman, New York Metzger W (1934) Beobachtungen über phänomenale Identität. Psychol Forsch 19:1–60 Remijn GB, Ito H, Nakajiama Y (2004) Audiovisual integration: an investigation of the “streaming-bouncing” phenomenon. J Physiol Anthropol Appl Human Sci 23:243–247 Sekuler R, Sekuler AB, Lau R (1997) Sound alters visual motion perception. Nature 385:308 Watanabe K, Shimojo S (2001) When sound affects vision: effects of auditory grouping on visual motion perception. Psychol Sci 12:109–116 Zhou F, Wong V, Sekuler R (2007) Multi-sensory integration of spatio-temporal segmentation cues: one plus one does not always equal two. Exp Brain Res 180:641–654 Suggested Readings Some of the concepts illustrated in this chapter can be found, in an extended way, in the following books: Gilat A (2008) MATLAB: an introduction with applications. Wiley, Mahwah, N.J. Hunt BR, Lipsaman RL et al (2006) A guide to MATLAB: for beginners and experienced users, 2nd edn. Cambridge University Press, Cambridge, United Kingdom Kattan PI (2008) MATLAB for beginners: a gentle approach, Revised edn. Lulu.com, Raleigh, NC, United States Rosenbaum DA (2007) MATLAB for behavioral scientists. Lawrence Erlbaum Associates, Hoboken, N.J