Undefined function or method 'ReverseCorrect'
Mostra commenti meno recenti
I keep getting the error message "undefined function or method 'ReverseCorrect' for input arguments of type 'double'." I used this exact script a few months ago and had no issues but cannot find the source of the issue. I have pasted two scripts below this message. Any input would be greatly appreciated.
Main script:
% This version of ERNBeh was made on 6/3/13. It combines the previous ERNBeh with the identification and removal of bad blocks and bad participants
% Set path to where folder full of text files and participant file is
% The text files are the files written by the Flankers presentation file.
% The Participant file should be a text file with all the participant
% numbers in a column.
path='C:\Users\ch\Desktop\Culture & ERP\Data Analysis\ERN Behavioral MATLAB - Spring 2013\TXT Files\';
% Define pfile as the name of the participant file
pfile=[path,'Subject List.txt'];
% Assign file id number to the participant file
fid1=fopen(pfile);
% Make matrix for the output to be written into
output=[];
BlockErrOutput=zeros(112,11);
StringErrOutput=zeros(112,11);
pcount=1;
% Start loop to go through all the participants in the participant list
for nparticipants=1:112
% Define id as the participant number
id=fgetl(fid1);
% Define the file2 as the text file name
file2=[path,id,'.txt'];
% Assign a file id number for the text file
fid2=fopen(file2);
% Start loop to read the text file from presentation
for line=1:400
% Read a line of the text file and put it in a column called "a"
a=fscanf(fid2,'%f',5);
% Write column "a" as a row in a matrix called "b"
b(line,:)=a;
% End the file reading loop. At this point the contents of the text
% file is in matrix "b".
end
% Create a column of zeros
c=zeros(400,1);
% Stick the column of zeros onto matrix "b" to create matrix "d". The value
% of that sixth column will indicate whether that trial is being used. The
% Value of 0 indicates that the trial is usable.
d=[b c];
% Start a loop to read one block of data into a matrix called block
% Make the block matrix and trial counter
BlockErrOutput(pcount,1)=pcount;
StringErrOutput(pcount,1)=pcount;
blockcounter=0;
blocks=1;
for blocks = 1:10
trialcounter=1;
block=[];
% Write the first 40 rows from d into a matrix called "block"
for rows=1:40
block=[block; d((blockcounter*40+trialcounter),:)];
% And advance the counter
trialcounter=trialcounter+1;
end
% Run the Reverse Block Correcting function on this block. The corrected
% block is in a matrix named "cb"
cb= ReverseCorrect(block);
% Run the Block Error Counting function on this block
NoBlErr = BlockErrorCount(cb);
BlockErrOutput(pcount,(blockcounter+2))=NoBlErr;
if NoBlErr > 9
linecounter=1;
for line = 1:40
cb(linecounter,6)=1;
linecounter=linecounter+1;
end
end
StrErr=StringErr(cb);
StringErrOutput(pcount,(blockcounter+2))=StrErr;
if StrErr==1
linecounter2=1;
for line2 = 1:40
cb(linecounter2,6)=2;
linecounter2=linecounter2+1;
end
end
counter3=1;
for Line3 = 1:40
d((counter3+blockcounter*40),5) = cb(counter3,5);
d((counter3+blockcounter*40),6) = cb(counter3,6);
counter3=counter3+1;
end
blockcounter=blockcounter+1;
end
IDnum=pcount;
[AvgRT] = AverageRT(d);
% Create variables for the mean of correct and incorrect trials from the function
[AvRTforCorr, AvRTforIncorr] = CalcAvgforCandI(d);
% Creates variable for the proportion correct from the function
OverallAccuracy=Accuracy(d);
UsableAccuracy=UseAcc(d);
% Creates variables for Post Error RT and Post Error Accuracy
[PostErrRT, PostErrAcc] = PostError(d);
[PostCorrRT, PostCorrAcc] = PostCorrect(d);
NumErr=NumberErrs(d);
% Write participant number, Overall Accuracy (inlcuding dropped blocks) Average RT, Average RT for correct trials,
% Average RT for incorrect trials, Proportion Correct (from usable blocks), Post Error RT,
% Post Error Accuracy, Post Correct RT, Post Correct Accuracy, and Total # of Errors to bottom of output file
output=[output; IDnum OverallAccuracy AvgRT AvRTforCorr AvRTforIncorr UsableAccuracy PostErrRT PostErrAcc PostCorrRT PostCorrAcc NumErr];
pcount=pcount+1;
% End loop through participants
end
"Reverse Correct" script:
% This function identifies reversed blocks and corrects them
function [corrblock] = ReverseCorrect(block)
% Creates variable for the number of incorrect triels during the block
% using Block Error Count function
NoIncorr = BlockErrorCount(block);
% If there are more than 30 incorrect trials in the block (the block is
% reversed)
if NoIncorr > 30
counter2=1;
% Reverse the coding of the 5th column (correct vs. incorrect)
for line=1:40
if block (counter2,5)==1
block (counter2,5)=4;
counter2=counter2+1;
elseif block (counter2,5)==4
block(counter2,5)=1;
counter2=counter2+1;
else
counter2=counter2+1;
end
end
% The reverse coded block replaces the original block
corrblock=block;
else
% Or if the block is not reverse-coded then the output of the function
% will be the same ast the input of the function
corrblock=block;
end
end
2 Commenti
Walter Roberson
il 4 Giu 2013
It is recommended to avoid assigning to a variable named "path", as doing so interferes with using the MATLAB function named path()
Christina
il 4 Giu 2013
Risposte (1)
Walter Roberson
il 4 Giu 2013
Modificato: Walter Roberson
il 4 Giu 2013
The ReverseCorrect function is not stored in a file named ReverseCorrect.m or else that file is not on the MATLAB path.
Check
which -all ReverseCorrect
Categorie
Scopri di più su MATLAB Function Block Editor in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!