Code interpretation: a question from a MATLAB novice

3 views (last 30 days)

Dear MATLAB gurus,

I was given a significant bit of code from another University which I was asked to run where I am currently working.  It is a psychology experiment which refers to pictures and sounds, stimuli which I have been given.  So in theory, I should have just had to re-direct the directories and change the port-code. I have downloaded PsychToolbox, which appears necessary for the experiment to run.  When I run the code now, I can't get past the initial text screen ["OK! We are about to begin..."].  Any idea of what aspect in the code is halting this progression?   I realize the code below is a LOT, but, to be honest, I'm pretty desperate, and any help would be much appreciated!

Thanks!

[function DANVAmod2(run,subj)

addpath('C:\toolbox\Psychtoolbox\downloadPsychtoolbox') addpath('C:\Users\aiyer\Documents\MATLAB\DANVA2') studyRoot='C:\Users\aiyer\Documents\MATLAB' AssertOpenGL; InitializePsychSound;

%initialize the inpout32.dll low-level I/O driver %config_io; %write a value to LPT3 %address = hex2dec('EC00');

KbName('UnifyKeynames'); ButtonOne = KbName('1!'); ButtonTwo = KbName('2@'); ButtonThree = KbName('3#'); ButtonFour = KbName('4$'); Go = KbName('space');

white = [255 255 255]; black = [0 0 0]; gray = [105 105 105]; blue = [176 196 222];red=[255 0 0];

fid = fopen(fullfile(studyRoot,['run_', num2str(run),'_subj_',num2str(subj),'.txt']), 'w'); fprintf(fid, '%s\t%s\t%s\t%s\t%s\t%s\n', 'EventType', 'StimulusNumber', 'ReactionTime','Response','CorrectResponse','Intensity');

screenid = max(Screen('Screens')); screenRect = Screen('Rect', screenid);

Width=RectWidth(screenRect); Height=RectHeight(screenRect); CenterWidth = Width/2; CenterHeight = Height/2; pictureRect = [400 130 1280 695];

MainWindow = Screen('OpenWindow', screenid, black);

blank = Screen('OpenOffScreenWindow', screenid, black, screenRect);

loading = Screen('OpenOffScreenWindow', screenid, black, screenRect); Screen('TextSize', loading , 30); DrawFormattedText(loading, 'OK! We are about to begin ... ', 'center', 'center', white);

Screen('CopyWindow', loading, MainWindow, screenRect, screenRect); Screen('Flip', MainWindow);

%scale = imread(fullfile(studyRoot,'DANVA2', 'scale.jpg'));

for i = 1:24 Image = imread(fullfile(studyRoot,'DANVA2', 'adult faces', [num2str(i),'.jpg'])); AdultScreen(i)= Screen('OpenOffScreenWindow', screenid, black, screenRect); Screen('PutImage', AdultScreen(i), Image); end

for i = 1:24 Image = imread(fullfile(studyRoot,'DANVA2', 'child faces', ['ch',num2str(i),'.jpg'])); ChildScreen(i)= Screen('OpenOffScreenWindow', screenid, black, screenRect); Screen('PutImage', ChildScreen(i), Image); end

Instructions = Screen('OpenOffScreenWindow', screenid, black, screenRect); Screen('TextSize', Instructions , 30); %%Text Size Screen('TextFont', Instructions, 'Helvetica'); %%Text Font DrawFormattedText(Instructions , 'For the next several minutes you will play a game in which\n\n you will see a bunch of FACES and hear a bunch of VOICES.\n\nEach face and voice will be either HAPPY, SAD, ANGRY, or FEARFUL.\n\n\nYour job is to identify which EMOTION goes with each FACE and VOICE.\n\n\nPress SPACEBAR to continue.', 'center', 'center', white)%%Text

Instructions2 = Screen('OpenOffScreenWindow', screenid, black, screenRect); Screen('TextSize', Instructions2 , 30); %%Text Size Screen('TextFont', Instructions2, 'Helvetica'); %%Text Font DrawFormattedText(Instructions2 , 'When you see a HAPPY face or hear a HAPPY voice, press 1\n\n\nWhen you see a SAD face or hear a SAD voice, press 2\n\n\nWhen you see an ANGRY face or hear an ANGRY voice, press 3\n\n\nWhen you see see a FEARFUL face or hear a FEARFUL voice, press 4\n\n\n\nPress SPACEBAR to BEGIN the game.', 'center', 'center', white)%%Text

EndScreen = Screen('OpenOffScreenWindow', screenid, black, screenRect); Screen('TextSize', EndScreen , 30); DrawFormattedText(EndScreen , 'Task complete.', 'center', 'center', white);

HideCursor;

BLOCK=shuffle([1 2 3 4]);

Screen('CopyWindow', Instructions, MainWindow, screenRect, screenRect); Screen('Flip', MainWindow);

while 1 [pressed secs keycode] = KbCheck; if find(keycode)==Go; Waitsecs(.2) break; end end

Screen('CopyWindow', Instructions2, MainWindow, screenRect, screenRect); Screen('Flip', MainWindow);

while 1 [pressed secs keycode] = KbCheck; if find(keycode)==Go; Waitsecs(.2) break; end end

for idx = 1:length(BLOCK)

    if BLOCK(idx) == 1;
       Answer =    [1	4   3	1   3	2   1	4   4	1   2	3   2	2   3	4   2	2 4 3	4   3	1   1];
       Intensity = [1   2   1   2   2   1   2   2   1   2   1   2   2   2   1   2   2   1 1 2   1   1   1   1];
       CODE =      [1   8   5   2   6   3   2   8   7   2   3   6   4   4   5   8   4   3 7 6   7   5   1   1];
        for i = 1:24;
            outp(address,CODE(i)); %%send triggers
            Waitsecs(.005)
            outp(address,0)
            Screen('CopyWindow', AdultScreen(i), MainWindow, screenRect, screenRect);
            Screen('TextSize',MainWindow, 50);
            DrawFormattedText(MainWindow, 'Happy', .25*Width,.82*Height, white);
            DrawFormattedText(MainWindow, 'Sad',   .4*Width,.82*Height,  white);
            DrawFormattedText(MainWindow, 'Angry', .55*Width,.82*Height,  white);
            DrawFormattedText(MainWindow, 'Fearful',.7*Width,.82*Height,  white);
            Screen('Flip', MainWindow);
            Start = GetSecs;
            while 1;
                [pressed secs keycode] = KbCheck;
                if pressed~=0;
                    if find(keycode)==ButtonOne;
                        End = GetSecs;
                        Screen('CopyWindow', AdultScreen(i), MainWindow, screenRect, screenRect);
                        DrawFormattedText(MainWindow, 'Happy', .25*Width,.82*Height, white);
                        Screen('Flip', MainWindow);
                        Waitsecs(1);
                        data(idx,i,:) = [BLOCK(idx) i End-Start 1 Answer(i) Intensity(i)];
                        fprintf(fid,'%1.0f\t%1.0f\t%3.3f\t%1.0f\t%1.0f\t%1.0f\n', data(idx,i,:))
                        break;
                    elseif find(keycode)==ButtonTwo;
                        End = GetSecs;
                        Screen('CopyWindow', AdultScreen(i), MainWindow, screenRect, screenRect);
                        DrawFormattedText(MainWindow, 'Sad', .4*Width,.82*Height,  white);
                        Screen('Flip', MainWindow);
                        Waitsecs(1);
                        data(idx,i,:) = [BLOCK(idx) i End-Start 2 Answer(i) Intensity(i)];
                        fprintf(fid,'%1.0f\t%1.0f\t%3.3f\t%1.0f\t%1.0f\t%1.0f\n', data(idx,i,:))
                        break;
                    elseif find(keycode)==ButtonThree;
                        End = GetSecs;
                        Screen('CopyWindow', AdultScreen(i), MainWindow, screenRect, screenRect);
                        DrawFormattedText(MainWindow, 'Angry', .55*Width,.82*Height, white);
                        Screen('Flip', MainWindow);
                        Waitsecs(1);
                        data(idx,i,:) = [BLOCK(idx) i End-Start 3 Answer(i) Intensity(i)];
                        fprintf(fid,'%1.0f\t%1.0f\t%3.3f\t%1.0f\t%1.0f\t%1.0f\n', data(idx,i,:))
                        break;
                    elseif find(keycode)==ButtonFour;
                        End = GetSecs;
                        Screen('CopyWindow', AdultScreen(i), MainWindow, screenRect, screenRect);
                        DrawFormattedText(MainWindow, 'Fearful', .7*Width,.82*Height,  white);
                        Screen('Flip', MainWindow);
                        Waitsecs(1);
                        data(idx,i,:) = [BLOCK(idx) i End-Start 4 Answer(i) Intensity(i)];
                        fprintf(fid,'%1.0f\t%1.0f\t%3.3f\t%1.0f\t%1.0f\t%1.0f\n', data(idx,i,:))
                        break;
                    else
                    end
                end
                if GetSecs-Start>3;
                    Screen('CopyWindow', blank, MainWindow, screenRect, screenRect);
                    DrawFormattedText(MainWindow, 'Happy', .25*Width,.82*Height, white);
                    DrawFormattedText(MainWindow, 'Sad', .4*Width,.82*Height,  white);
                    DrawFormattedText(MainWindow, 'Angry', .55*Width,.82*Height,  white);
                    DrawFormattedText(MainWindow, 'Fearful', .7*Width,.82*Height,  white);
                    Screen('Flip', MainWindow);
                end
            end
            Screen('CopyWindow', blank, MainWindow, screenRect, screenRect);
            Screen('Flip', MainWindow);
            Waitsecs(1);
        end
    elseif BLOCK(idx)==2;
        Answer =    [3	1   1	4   2	2   3	1   3	2   4	1   2	3   4	1   2	4 4 3	2   4	1   3];
        Intensity = [2	1   2	2   1	1   1	1   2	2   2	2   1   2   2   1   2   1 1 1   2   1   2   1];
        CODE =      [6  1   2   8   3   3   5   1   6   4   8   2   3   6   8   1   4   7 7 5   4   7   2   5];
        for i = 1:24;
            outp(address,CODE(i)+10); %%send triggers
            Waitsecs(.005)
            outp(address,0)
            Screen('CopyWindow', ChildScreen(i), MainWindow, screenRect, screenRect);
            Screen('TextSize',MainWindow, 50);
            DrawFormattedText(MainWindow, 'Happy', .25*Width,.82*Height, white);
            DrawFormattedText(MainWindow, 'Sad', .4*Width,.82*Height,  white);
            DrawFormattedText(MainWindow, 'Angry', .55*Width,.82*Height,  white);
            DrawFormattedText(MainWindow, 'Fearful', .7*Width,.82*Height,  white);
            Screen('Flip', MainWindow);
            Start = GetSecs;
            while 1;
                [pressed secs keycode] = KbCheck;
                if pressed~=0;
                    if find(keycode)==ButtonOne;
                        End = GetSecs;
                        Screen('CopyWindow', ChildScreen(i), MainWindow, screenRect, screenRect);
                        DrawFormattedText(MainWindow, 'Happy', .25*Width,.82*Height, white);
                        Screen('Flip', MainWindow);
                        Waitsecs(1);
                        data(idx,i,:) = [BLOCK(idx) i End-Start 1 Answer(i) Intensity(i)];
                        fprintf(fid,'%1.0f\t%1.0f\t%3.3f\t%1.0f\t%1.0f\t%1.0f\n', data(idx,i,:))
                        break;
                    elseif find(keycode)==ButtonTwo;
                        End = GetSecs;
                        Screen('CopyWindow', ChildScreen(i), MainWindow, screenRect, screenRect);
                        DrawFormattedText(MainWindow, 'Sad', .4*Width,.82*Height,  white);
                        Screen('Flip', MainWindow);
                        Waitsecs(1);
                        data(idx,i,:) = [BLOCK(idx) i End-Start 2 Answer(i) Intensity(i)];
                        fprintf(fid,'%1.0f\t%1.0f\t%3.3f\t%1.0f\t%1.0f\t%1.0f\n', data(idx,i,:))
                        break;
                    elseif find(keycode)==ButtonThree;
                        End = GetSecs;
                        Screen('CopyWindow', ChildScreen(i), MainWindow, screenRect, screenRect);
                        DrawFormattedText(MainWindow, 'Angry', .55*Width,.82*Height, white);
                        Screen('Flip', MainWindow);
                        Waitsecs(1);
                       data(idx,i,:) = [BLOCK(idx) i End-Start 3 Answer(i) Intensity(i)];
                        fprintf(fid,'%1.0f\t%1.0f\t%3.3f\t%1.0f\t%1.0f\t%1.0f\n', data(idx,i,:))
                        break;
                    elseif find(keycode)==ButtonFour;
                        End = GetSecs;
                        Screen('CopyWindow', ChildScreen(i), MainWindow, screenRect, screenRect);
                        DrawFormattedText(MainWindow, 'Fearful', .7*Width,.82*Height,  white);
                        Screen('Flip', MainWindow);
                        Waitsecs(1);
                        data(idx,i,:) = [BLOCK(idx) i End-Start 4 Answer(i) Intensity(i)];
                        fprintf(fid,'%1.0f\t%1.0f\t%3.3f\t%1.0f\t%1.0f\t%1.0f\n', data(idx,i,:))
                        break;
                    else
                    end
                end
                if GetSecs-Start>3;
                    Screen('CopyWindow', blank, MainWindow, screenRect, screenRect);
                    DrawFormattedText(MainWindow, 'Happy', .25*Width,.82*Height, white);
                    DrawFormattedText(MainWindow, 'Sad', .4*Width,.82*Height,  white);
                    DrawFormattedText(MainWindow, 'Angry', .55*Width,.82*Height,  white);
                    DrawFormattedText(MainWindow, 'Fearful', .7*Width,.82*Height,  white);
                    Screen('Flip', MainWindow);
                end
            end
            Screen('CopyWindow', blank, MainWindow, screenRect, screenRect);
            Screen('Flip', MainWindow);
            Waitsecs(1);
        end
    elseif BLOCK(idx)==3;
         Answer =    [3	2   1	3   2	1   2	4    1	3   4	2   1	3   4	2   4	3 2  3	 4   1	 4   1];
         Intensity = [2	2   2	1   1	1   1	1    1	2   2	1   2	2   1	2   2	1 2  1	 2   2	 1   1];
         CODE =      [6 4   2   5   3   1   3   7    1  6   8   3   2   6   7   4   8   5 4  5   8   2   7   1];
        for i = 1:24;
            [y, freq, nbits] = wavread(fullfile(studyRoot,'DANVA2', 'adult voices', ['Adult_',num2str(i),'.wav']) );
            wavedata = y';
            nrchannels = size(wavedata,1);
            pahandle = PsychPortAudio('Open', [], [], 0, freq,  nrchannels);
            Screen('CopyWindow', blank, MainWindow, screenRect, screenRect);
            Screen('TextSize',MainWindow, 50);
            DrawFormattedText(MainWindow, 'Happy', .25*Width,CenterHeight, white);
            DrawFormattedText(MainWindow, 'Sad',   .4*Width,CenterHeight,  white);
            DrawFormattedText(MainWindow, 'Angry', .55*Width,CenterHeight, white);
            DrawFormattedText(MainWindow, 'Fearful',.7*Width,CenterHeight, white);
            Screen('Flip', MainWindow);
            PsychPortAudio('FillBuffer', pahandle, wavedata);
            outp(address,CODE(i)+20); %%send triggers
            Waitsecs(.005)
            outp(address,0)
            PsychPortAudio('Start', pahandle, 1, 0, 1);   Start = GetSecs;
            while 1;
                [pressed secs keycode] = KbCheck;
                if pressed~=0;
                    if find(keycode)==ButtonOne;
                        End = GetSecs;
                        Screen('CopyWindow', blank, MainWindow, screenRect, screenRect);
                        DrawFormattedText(MainWindow, 'Happy', .25*Width,CenterHeight, white);
                        Screen('Flip', MainWindow);
                        Waitsecs(1);
                        data(idx,i,:) = [BLOCK(idx) i End-Start 1 Answer(i) Intensity(i)];
                        fprintf(fid,'%1.0f\t%1.0f\t%3.3f\t%1.0f\t%1.0f\t%1.0f\n', data(idx,i,:))
                        break;
                    elseif find(keycode)==ButtonTwo;
                        End = GetSecs;
                        Screen('CopyWindow',  blank, MainWindow, screenRect, screenRect);
                        DrawFormattedText(MainWindow, 'Sad', .4*Width,CenterHeight,  white);
                        Screen('Flip', MainWindow);
                        Waitsecs(1);
                        data(idx,i,:) = [BLOCK(idx) i End-Start 2 Answer(i) Intensity(i)];
                        fprintf(fid,'%1.0f\t%1.0f\t%3.3f\t%1.0f\t%1.0f\t%1.0f\n', data(idx,i,:))
                        break;
                    elseif find(keycode)==ButtonThree;
                        End = GetSecs;
                        Screen('CopyWindow',  blank, MainWindow, screenRect, screenRect);
                        DrawFormattedText(MainWindow, 'Angry', .55*Width,CenterHeight, white);
                        Screen('Flip', MainWindow);
                        Waitsecs(1);
                        data(idx,i,:) = [BLOCK(idx) i End-Start 3 Answer(i) Intensity(i)];
                        fprintf(fid,'%1.0f\t%1.0f\t%3.3f\t%1.0f\t%1.0f\t%1.0f\n', data(idx,i,:))
                        break;
                    elseif find(keycode)==ButtonFour;
                        End = GetSecs;
                        Screen('CopyWindow',  blank, MainWindow, screenRect, screenRect);
                        DrawFormattedText(MainWindow, 'Fearful', .7*Width,CenterHeight,  white);
                        Screen('Flip', MainWindow);
                        Waitsecs(1);
                        data(idx,i,:) = [BLOCK(idx) i End-Start 4 Answer(i) Intensity(i)];
                        fprintf(fid,'%1.0f\t%1.0f\t%3.3f\t%1.0f\t%1.0f\t%1.0f\n', data(idx,i,:))
                        break;
                    else
                    end
                end
            end
            Screen('CopyWindow', blank, MainWindow, screenRect, screenRect);
            Screen('Flip', MainWindow);
            Waitsecs(3.5);
            PsychPortAudio('Close', pahandle); 
        end
    elseif BLOCK(idx)==4;
        Answer =    [1  2   3   3   1   4   3   2   4   1   2   1   4   3   2   4   1   2 3 4   3   4   1   2];
        Intensity = [1  2   2   1   2   2   1   1   1   1   2   2   1   1   1   2   1   2 2 1   2   2   2   1];
        CODE =      [1  4   6   5   2   8   5   3   7   1   4   2   7   5   3   8   1   4 6 7   6   8   2   3];
        for i = 1:24;
            [y, freq, nbits] = wavread(fullfile(studyRoot,'DANVA2', 'child voices', ['child',num2str(i),'.wav']) );
            wavedata = y';
            nrchannels = size(wavedata,1);
            pahandle = PsychPortAudio('Open', [], [], 0, freq,  nrchannels);
            Screen('CopyWindow', blank, MainWindow, screenRect, screenRect);
            Screen('TextSize',MainWindow, 50);
            DrawFormattedText(MainWindow, 'Happy', .25*Width,CenterHeight, white);
            DrawFormattedText(MainWindow, 'Sad',   .4*Width,CenterHeight,  white);
            DrawFormattedText(MainWindow, 'Angry', .55*Width,CenterHeight, white);
            DrawFormattedText(MainWindow, 'Fearful',.7*Width,CenterHeight, white);
            Screen('Flip', MainWindow);
            PsychPortAudio('FillBuffer', pahandle, wavedata);
            outp(address,CODE(i)+30); %%send triggers
            Waitsecs(.005)
            outp(address,0)
            PsychPortAudio('Start', pahandle, 1, 0, 1);   Start = GetSecs;
            while 1;
                [pressed secs keycode] = KbCheck;
                if pressed~=0;
                    if find(keycode)==ButtonOne;
                        End = GetSecs;
                        Screen('CopyWindow', blank, MainWindow, screenRect, screenRect);
                        DrawFormattedText(MainWindow, 'Happy', .25*Width,CenterHeight, white);
                        Screen('Flip', MainWindow);
                        Waitsecs(1);
                        data(idx,i,:) = [BLOCK(idx) i End-Start 1 Answer(i) Intensity(i)];
                        fprintf(fid,'%1.0f\t%1.0f\t%3.3f\t%1.0f\t%1.0f\t%1.0f\n', data(idx,i,:))
                        break;
                    elseif find(keycode)==ButtonTwo;
                        End = GetSecs;
                        Screen('CopyWindow',  blank, MainWindow, screenRect, screenRect);
                        DrawFormattedText(MainWindow, 'Sad', .4*Width,CenterHeight,  white);
                        Screen('Flip', MainWindow);
                        Waitsecs(1);
                      data(idx,i,:) = [BLOCK(idx) i End-Start 2 Answer(i) Intensity(i)];
                        fprintf(fid,'%1.0f\t%1.0f\t%3.3f\t%1.0f\t%1.0f\t%1.0f\n', data(idx,i,:))
                        break;
                    elseif find(keycode)==ButtonThree;
                        End = GetSecs;
                        Screen('CopyWindow',  blank, MainWindow, screenRect, screenRect);
                        DrawFormattedText(MainWindow, 'Angry', .55*Width,CenterHeight, white);
                        Screen('Flip', MainWindow);
                        Waitsecs(1);
                       data(idx,i,:) = [BLOCK(idx) i End-Start 3 Answer(i) Intensity(i)];
                        fprintf(fid,'%1.0f\t%1.0f\t%3.3f\t%1.0f\t%1.0f\t%1.0f\n', data(idx,i,:))
                        break;
                    elseif find(keycode)==ButtonFour;
                        End = GetSecs;
                        Screen('CopyWindow',  blank, MainWindow, screenRect, screenRect);
                        DrawFormattedText(MainWindow, 'Fearful', .7*Width,CenterHeight,  white);
                        Screen('Flip', MainWindow);
                        Waitsecs(1);
                        data(idx,i,:) = [BLOCK(idx) i End-Start 4 Answer(i) Intensity(i)];
                        fprintf(fid,'%1.0f\t%1.0f\t%3.3f\t%1.0f\t%1.0f\t%1.0f\n', data(idx,i,:))
                        break;
                    else
                    end
                end
            end
            Screen('CopyWindow', blank, MainWindow, screenRect, screenRect);
            Screen('Flip', MainWindow);
            Waitsecs(3.5);
            PsychPortAudio('Close', pahandle); 
        end
        continue;
    end
end

Screen('CopyWindow', EndScreen, MainWindow, screenRect, screenRect); Screen('Flip', MainWindow); Waitsecs(2)

Screen('CloseAll')

%%Happy = 1 %%Sad =2 %%Angry = 3; %%Fearful =4

%%High = 1; %%Low =2;

for intensity = 1:2; %%Loop through intensity for idx = 1:length(BLOCK); %%for each block for stim = 1:24; %% for each stimulus for answer = 1:4; %%Loop through type of response correct(data(idx,1,1),answer,intensity,:) = 0; end end end end

for intensity = 1:2; %%Loop through intensity for idx = 1:length(BLOCK); %%for each block for stim = 1:24; %% for each stimulus for answer = 1:4; %%Loop through type of response if squeeze(data(idx,stim,4)) == squeeze(data(idx,stim,5)) && squeeze(data(idx,stim,4))==answer && squeeze(data(idx,stim,6))==intensity && squeeze(data(idx,stim,6)); correct(data(idx,1,1),answer,intensity,:) = correct(data(idx,1,1),answer,intensity,:)+1; end end end end end

wrong(:,:,:,:) = 3-correct(:,:,:,:);

total = sum(wrong); grand_total = sum(sum(sum(wrong)));

total_high= sum(total(:,:,1)); total_low= sum(total(:,:,2));

total_happy_high = total(1,1,1); total_happy_low = total(1,1,2); total_happy = total_happy_high+total_happy_low;

total_sad_high=total(1,2,1); total_sad_low=total(1,2,2); total_sad = total_sad_high+total_sad_low;

total_angry_high=total(1,3,1); total_angry_low=total(1,3,2); total_angry = total_angry_high+total_angry_low;

total_fearful_high=total(1,4,1); total_fearful_low =total(1,4,2); total_fearful = total_fearful_high+total_fearful_low;

total_happy_adult_faces = squeeze(wrong(1,1,1))+squeeze(wrong(1,1,2)); total_sad_adult_faces=squeeze(wrong(1,2,1))+squeeze(wrong(1,2,2)); total_angry_adult_faces = squeeze(wrong(1,3,1))+squeeze(wrong(1,3,2)); total_fearful_adult_faces = squeeze(wrong(1,4,1))+squeeze(wrong(1,4,2));

total_happy_child_faces =squeeze(wrong(2,1,1))+squeeze(wrong(2,1,2)); total_sad_child_faces=squeeze(wrong(2,2,1))+squeeze(wrong(2,2,2)); total_angry_child_faces = squeeze(wrong(2,3,1))+squeeze(wrong(2,3,2)); total_fearful_child_faces = squeeze(wrong(2,4,1))+squeeze(wrong(2,4,2));

total_happy_adult_voices =squeeze(wrong(3,1,1))+squeeze(wrong(3,1,2)); total_sad_adult_voices=squeeze(wrong(3,2,1))+squeeze(wrong(3,2,2)); total_angry_adult_voices = squeeze(wrong(3,3,1))+squeeze(wrong(3,3,2)); total_fearful_adult_voices = squeeze(wrong(3,4,1))+squeeze(wrong(3,4,2));

total_happy_child_voices =squeeze(wrong(4,1,1))+squeeze(wrong(4,1,2)); total_sad_child_voices=squeeze(wrong(4,2,1))+squeeze(wrong(4,2,2)); total_angry_child_voices = squeeze(wrong(4,3,1))+squeeze(wrong(4,3,2)); total_fearful_child_voices = squeeze(wrong(4,4,1))+squeeze(wrong(4,4,2));

fprintf(fid,'%s\n', 'Adult Faces') fprintf(fid,'%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\n', 'Happy/High', 'Happy/Low', 'Sad/High','Sad/Low','Angry/High','Angry/Low','Fearful/High', 'Fearful/Low'); fprintf(fid,'%1.0f\t%1.0f\t%1.0f\t%1.0f\t%1.0f\t%1.0f\t%1.0f\t%1.0f\n',squeeze(wrong(1,1,1)),squeeze(wrong(1,1,2)),squeeze(wrong(1,2,1)),squeeze(wrong(1,2,2)),squeeze(wrong(1,3,1)),squeeze(wrong(1,3,2)),squeeze(wrong(1,4,1)),squeeze(wrong(1,4,2)));

fprintf(fid,'%s\n', 'Child Faces') fprintf(fid,'%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\n','Happy/High', 'Happy/Low', 'Sad/High','Sad/Low','Angry/High','Angry/Low','Fearful/High', 'Fearful/Low'); fprintf(fid,'%1.0f\t%1.0f\t%1.0f\t%1.0f\t%1.0f\t%1.0f\t%1.0f\t%1.0f\n',squeeze(wrong(2,1,1)),squeeze(wrong(2,1,2)),squeeze(wrong(2,2,1)),squeeze(wrong(2,2,2)),squeeze(wrong(2,3,1)),squeeze(wrong(2,3,2)),squeeze(wrong(2,4,1)),squeeze(wrong(2,4,2)));

fprintf(fid,'%s\n', 'Adult Voices') fprintf(fid,'%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\n','Happy/High', 'Happy/Low', 'Sad/High','Sad/Low','Angry/High','Angry/Low','Fearful/High', 'Fearful/Low'); fprintf(fid,'%1.0f\t%1.0f\t%1.0f\t%1.0f\t%1.0f\t%1.0f\t%1.0f\t%1.0f\n',squeeze(wrong(3,1,1)),squeeze(wrong(3,1,2)),squeeze(wrong(3,2,1)),squeeze(wrong(3,2,2)),squeeze(wrong(3,3,1)),squeeze(wrong(3,3,2)),squeeze(wrong(3,4,1)),squeeze(wrong(3,4,2)));

fprintf(fid,'%s\n', 'Child Voices') fprintf(fid,'%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\n','Happy/High', 'Happy/Low', 'Sad/High','Sad/Low','Angry/High','Angry/Low','Fearful/High', 'Fearful/Low'); fprintf(fid,'%1.0f\t%1.0f\t%1.0f\t%1.0f\t%1.0f\t%1.0f\t%1.0f\t%1.0f\n',squeeze(wrong(4,1,1)),squeeze(wrong(4,1,2)),squeeze(wrong(4,2,1)),squeeze(wrong(4,2,2)),squeeze(wrong(4,3,1)),squeeze(wrong(4,3,2)),squeeze(wrong(4,4,1)),squeeze(wrong(4,4,2)));

fprintf(fid,'%s\t%2.0f\n', 'Total Wrong',grand_total) fprintf(fid,'%s\t%2.0f\n', 'Total Wrong High',total_high) fprintf(fid,'%s\t%2.0f\n', 'Total Wrong Low',total_low) fprintf(fid,'%s\t%2.0f\n', 'Total Wrong Happy/High',total_happy_high) fprintf(fid,'%s\t%2.0f\n', 'Total Wrong Happy/Low',total_happy_low) fprintf(fid,'%s\t%2.0f\n', 'Total Wrong Sad/High',total_sad_high) fprintf(fid,'%s\t%2.0f\n', 'Total Wrong Sad/Low',total_sad_low) fprintf(fid,'%s\t%2.0f\n', 'Total Wrong Angry/High',total_angry_high) fprintf(fid,'%s\t%2.0f\n', 'Total Wrong Angry/Low',total_angry_low) fprintf(fid,'%s\t%2.0f\n', 'Total Wrong Fearful/High',total_fearful_high) fprintf(fid,'%s\t%2.0f\n', 'Total Wrong Fearful/Low',total_fearful_low) fprintf(fid,'%s\t%2.0f\n', 'Total Wrong Happy',total_happy) fprintf(fid,'%s\t%2.0f\n', 'Total Wrong Sad',total_sad) fprintf(fid,'%s\t%2.0f\n', 'Total Wrong Angry',total_angry) fprintf(fid,'%s\t%2.0f\n', 'Total Wrong Fearful',total_fearful)

fprintf(fid,'%s\t%2.0f\n', 'Total Wrong Happy Adult Faces',total_happy_adult_faces) fprintf(fid,'%s\t%2.0f\n', 'Total Wrong Sad Adult Faces',total_sad_adult_faces) fprintf(fid,'%s\t%2.0f\n', 'Total Wrong Angry Adult Faces',total_angry_adult_faces) fprintf(fid,'%s\t%2.0f\n', 'Total Wrong Fearful Adult Faces',total_fearful_adult_faces)

fprintf(fid,'%s\t%2.0f\n', 'Total Wrong Happy Child Faces',total_happy_child_faces) fprintf(fid,'%s\t%2.0f\n', 'Total Wrong Sad Child Faces',total_sad_child_faces) fprintf(fid,'%s\t%2.0f\n', 'Total Wrong Angry Child Faces',total_angry_child_faces) fprintf(fid,'%s\t%2.0f\n', 'Total Wrong Fearful Child Faces',total_fearful_child_faces)

fprintf(fid,'%s\t%2.0f\n', 'Total Wrong Happy Adult Voices',total_happy_adult_voices) fprintf(fid,'%s\t%2.0f\n', 'Total Wrong Sad Adult Voices',total_sad_adult_voices) fprintf(fid,'%s\t%2.0f\n', 'Total Wrong Angry Adult Voices',total_angry_adult_voices) fprintf(fid,'%s\t%2.0f\n', 'Total Wrong Fearful Adult Voices',total_fearful_adult_voices)

fprintf(fid,'%s\t%2.0f\n', 'Total Wrong Happy Child Voices',total_happy_child_voices) fprintf(fid,'%s\t%2.0f\n', 'Total Wrong Sad Child Voices',total_sad_child_voices) fprintf(fid,'%s\t%2.0f\n', 'Total Wrong Angry Child Voices',total_angry_child_voices) fprintf(fid,'%s\t%2.0f\n', 'Total Wrong Fearful Child Voices',total_fearful_child_voices)

fclose('all');

]

Answers (0)

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!