1. getting familiar with matlab - wordpress.comgetting familiar with matlab author joonyeol lee...
TRANSCRIPT
PSYCHOPHYSICAL EXPERIMENTS
A LETTER MATCHING TASKPOSNER
MENTAL REPRESENTATION
A letter-matching task
(Posner) – Chronometric
(reaction time task)
Reaction time (RT) of
subject is the dependent
variable.
Response time can show
how fast each
representation is activated
q) Why ‘both consonants’
condition takes longer for
response than ‘both vowels’
condition?
MEMORY COMPARISON TASK(MEMORY-SCANNING TASK)
SAUL STERNBERG
REPRESENTATIONS ARE TRANSFORMED
Saul Sternberg (1975) Memory comparison task
Exhausting vs. self-terminating search
WORD SUPERIORITY EFFECTREICHER
TWO ALTERNATIVE FORCED CHOICE PARADIGM
PARALLEL VS. SERIAL PROCESSES
Reicher (1969) Word superiority effect
Two alternative forced choice
Does the stimulus contain an A or E?
(press A or E)
SPATIAL ATTENTION TASKPOSNER CUING TASK
POSNER CUING TASK
FEATURE SEARCH VS.
CONJUNCTION SEARCHTREISMAN
FEATURE VS. CONJUNCTION SEARCH
STROOP TASKMULTIPLICITY OF MENTAL REPRESENTATIONS
MULTIPLICITY OF MENTAL REPRESENTATIONS
빨강
초록
파랑
노랑
검정
MULTIPLICITY OF MENTAL REPRESENTATIONS
빨강
초록
파랑
노랑
검정
XXXX
XXXX
XXXX
XXXXXXXX
MULTIPLICITY OF MENTAL REPRESENTATIONS
빨강
초록
파랑
노랑
검정
노랑
파랑
빨강
검정
초록
XXXX
XXXX
XXXX
XXXXXXXX
MODULES AND FUNCTIONS
clear all
clc
% Set constants
applications = 30;
max_admits_allowed = 10;
IQmean = 110;
IQsd = 20;
SATQmean = 500;
SATQsd = 100;
SATVmean = 500;
SATVsd = 100;
ECsd = 10;
GPAmean = 2.0;
GPAsd = 10;
SCRIPT
% Preallocate arrays using deal
[IQ SATQ SATV GPA Acad EC Dist] =
deal(zeros(applications,1));
% Generate dummy scores to test the program
IQ = IQmean + (randn(applications,1)) * IQsd;
SATQ = SATQmean + (randn(applications,1)) * SATQsd;
SATV = SATVmean + (randn(applications,1)) * SATVsd;
GPA = GPAmean + (randn(applications,1)) * GPAsd;
EC = abs(randn(applications,1) * ECsd);
Dist = abs(randn(applications,1));
Acad = SATQ + SATV + 100 * GPA;
% Normalize the scores
Acad = (Acad - min(Acad)) ./ (max(Acad)-min(Acad));
EC = (EC -min(EC)) ./(max(EC)-min(EC));
Dist = (Dist - min(Dist)) ./(max(Dist)-min(Dist));
% Create a Scores matrix, including, in the final column,
% each student's total score
Scores = [[1:applications]' Acad EC Dist];
Scores(:,5) = [Acad + EC + Dist];
SCRIPT
% Admit the top max_admits_allowed students (plus any ties)
SortedScores = sortrows(Scores,-5);
criterion = SortedScores(max_admits_allowed,5);
SortedScores(:,6) = 0;
SortedScores((SortedScores(:,5) >= criterion),6) = 1;
ScoresAndAcceptances = sortrows(SortedScores,1);
% Display the results
fprintf('App.\tAcad.\tExtra.\tDist.\tTotal\tAccept\n\n')
fprintf(...
'%4d\t%6.2f\t%6.2f\t%6.2f\t%6.2f\t%4d\n',ScoresAndAcceptances')
fprintf('\r')
Students_Accepted = find(ScoresAndAcceptances(:,6));
fprintf('Accepted Students:\n');
fprintf('%3d',Students_Accepted);
fprintf('\n\n')
fprintf('Cutoff score: %5.03f\n', criterion);
SCRIPT
%College_Admissions_Main.m
Clear_Start;
Set_Constants;
Generate_Dummy_Scores;
Normalize_Scores;
Create_Scores_Matrix;
Select_Students;
Display_Results;
DIVIDING INTO SMALL MODULES
SCRIPT VS. FUNCTION
% function mymean.m
function myresult = mymean(inputarray);
myresult = sum(inputarray)/length(inputarray)
Return
meanD = mymean([1 3 5 7 9])
meanE = mymean([pi 1492 6.02])
meanF = mymean([1:10])
meanD =
5
meanE =
500.3872
meanF =
5.5000
FUNCTION
FUNCTION
% normalize.m
function y = normalize(x)
y = (x-min(x))./(max(x)-min(x));
end
% normalize_split_two_args.m
% Splits array in first argument into
% lower and upper halves, using the
% criterion ('mean' or 'median')
% specified in the second argument
function [ly, uy] =
normalize_split_two_args(x,typeofsplit);
lx = [];
ux = [];
if strcmp(typeofsplit,'median') % median split
lx = x(x<=median(x));
ux = x(x>median(x));
elseif strcmp(typeofsplit,'mean') % mean split
lx = x(x<=mean(x));
ux = x(x>mean(x));
FUNCTION WITH MORE THAN ONE ARGUMENT
else % error feedback
disp(['Error: An invalid type of split'...
' in the call to normalize_split_two_args']);
[ly, uy] = deal(NaN);
return
end
ly = (lx - min(lx)) ./ (max(lx)- min(lx));
uy = (ux - min(ux)) ./ (max(ux)- min(ux));
return
% mean_and_trimmed_mean.m
function [y,ty] = mean_and_trimmed_mean(x)
y = mean(x);
ty = mean(trimmed(x));
return
function zz = trimmed(w)
w = sort(w);
zz = [w(2:end-1)];
return
CREATING MULTIPLE FUNCTIONS IN A FILE
% ComputeMeans_Fails.m
x = randperm(5).^2;
[theMean theTrimmedMean] = mean_and_trimmed_mean(x)
function [y,ty] = mean_and_trimmed_mean(x)
y = mean(x);
ty = mean(trimmed(x));
return
function zz = trimmed(w)
w = sort(w);
zz = [w(2:end-1)];
return
CREATING MULTIPLE FUNCTIONS IN A FILE
% ComputeMeans_Succeeds.m
function main
x = randperm(5).^2
[theMean theTrimmedMean] = mean_and_trimmed_mean(x)
return
end % main function
function [y,ty] = mean_and_trimmed_mean(x)
y = mean(x);
ty = mean(trimmed(x));
return
end % mean_and_trimmed_mean
function zz = trimmed(w)
w = sort(w);
zz = [w(2:end-1)];
return
end % trimmed
CREATING MULTIPLE FUNCTIONS IN A FILE
PLOTS
clear all
close all
figure(1)
theta_rad = linspace(0,4*(2*pi),100);
plot(theta_rad,sin(theta_rad));
CONTROLLING PLOTS
clear all
close all
figure(1)
theta_rad = linspace(0,4*(2*pi),100);
plot(theta_rad,sin(theta_rad));
axis([min(theta_rad) max(theta_rad)
min(sin(theta_rad)) max(sin(theta_rad))]);
CONTROLLING PLOTS
clear all
close all
figure(1)
theta_rad = linspace(0,4*(2*pi),100);
x = theta_rad;
y = sin(theta_rad);
plot(x,y);
x_offset = 1;
y_offset = 0.2;
xlim([min(x)-x_offset, max(x+x_offset)]);
ylim([min(y)-y_offset, max(y+y_offset)]);
CONTROLLING PLOTS
clear all
close all
figure(1)
theta_rad = linspace(0,4*(2*pi),100);
x = theta_rad;
y = sin(theta_rad);
plot(x,y, 'g-');
hold on
plot(x,y, 'bo');
x_offset = 1;
y_offset = 0.2;
xlim([min(x)-x_offset, max(x+x_offset)]);
ylim([min(y)-y_offset, max(y+y_offset)]);
CONTROLLING PLOTS
clear all
close all
figure(1)
theta_rad = 0:.1:2*pi;
x = theta_rad;
y = sin(theta_rad);
plot(x,y,'go-');
hold on
y = cos(theta_rad);
plot(x,y,'b-s');
x_offset = 1;
y_offset = 0.2;
xlim([min(x)-x_offset, max(x+x_offset)]);
ylim([min(y)-y_offset, max(y+y_offset)]);
shg
CONTROLLING PLOTS
figure(1)
theta_rad = 0:.1:2*pi;
x = theta_rad;
plot(x,sin(theta_rad),'c+:', x, cos(theta_rad),
'rd');
CONTROLLING PLOTS
clear all
close all
figure(1)
theta_rad = 0:.1:8*pi;
x = theta_rad;
y = sin(x);
plot(x,y,'g-');
hold on
x_offset = 0;
y_offset = .2;
axis([min(x)-x_offset, max(x)+x_offset, ...
min(y)-y_offset, max(y+y_offset)]);
plot(x,y,'o','color','r','markersize',6,...
'markeredgecolor','k','markerfacecolor','r');
xlabel('Time');
ylabel('Happiness');
title('Life has its ups and downs');
CONTROLLING PLOTS