Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
xData = level(1:100)';
yData = [trialData(1:100).correct]';
% no NaNs
ft = fittype( '0.5+(1-0.5-l)./(1+exp(-(x-alpha)/beta))', 'independent', 'x', 'dependent', 'y' );
opts = fitoptions( ft );
opts.Display = 'Off';
opts.Lower = [-Inf 0 0];
opts.StartPoint = [0.132903481469417 0.762038603323984 0];
opts.Upper = [Inf 1 1];
[fitresult, gof] = fit( xData, yData, ft, opts );
figure( 'Name', 'Example Psychophysical function fitting' );
subplot(5,1,1)
h = plot( fitresult, xData, yData ); title('First Half')
legend( h, 'responses vs. sample positions', 'fit', 'Location', 'NorthEast' );
% Label axes
xlabel( 'stimulus intensity' );
ylabel( 'Probability of correct response' );
grid on
% fit for second half
xData = level(101:200)';
yData = [trialData(101:200).correct]';
ft = fittype( '0.5+(1-0.5-l)./(1+exp(-(x-alpha)/beta))', 'independent', 'x', 'dependent', 'y' );
opts = fitoptions( ft );
opts.Display = 'Off';
opts.Lower = [-Inf 0 0];
opts.StartPoint = [0.132903481469417 0.762038603323984 0];
opts.Upper = [Inf 1 1];
[fitresult, gof] = fit( xData, yData, ft, opts );
subplot(5,1,2)
h = plot( fitresult, xData, yData ); title('Second Half')
legend( h, 'responses vs. sample positions', 'fit', 'Location', 'NorthEast' );
% Label axes
xlabel( 'stimulus intensity' );
ylabel( 'Probability of correct response' );
grid on
xData = level(201:300)';
yData = [trialData(101:200).correct]';
ft = fittype( '0.5+(1-0.5-l)./(1+exp(-(x-alpha)/beta))', 'independent', 'x', 'dependent', 'y' );
opts = fitoptions( ft );
opts.Display = 'Off';
opts.Lower = [-Inf 0 0];
opts.StartPoint = [0.132903481469417 0.762038603323984 0];
opts.Upper = [Inf 1 1];
[fitresult, gof] = fit( xData, yData, ft, opts );
subplot(5,1,3)
h = plot( fitresult, xData, yData ); title('Second Half')
legend( h, 'responses vs. sample positions', 'fit', 'Location', 'NorthEast' );
% Label axes
xlabel( 'stimulus intensity' );
ylabel( 'Probability of correct response' );
grid on
xData = level(301:400)';
yData = [trialData(101:200).correct]';
ft = fittype( '0.5+(1-0.5-l)./(1+exp(-(x-alpha)/beta))', 'independent', 'x', 'dependent', 'y' );
opts = fitoptions( ft );
opts.Display = 'Off';
opts.Lower = [-Inf 0 0];
opts.StartPoint = [0.132903481469417 0.762038603323984 0];
opts.Upper = [Inf 1 1];
[fitresult, gof] = fit( xData, yData, ft, opts );
subplot(5,1,4)
h = plot( fitresult, xData, yData ); title('Second Half')
legend( h, 'responses vs. sample positions', 'fit', 'Location', 'NorthEast' );
% Label axes
xlabel( 'stimulus intensity' );
ylabel( 'Probability of correct response' );
grid on
xData = level(401:500)';
yData = [trialData(101:200).correct]';
ft = fittype( '0.5+(1-0.5-l)./(1+exp(-(x-alpha)/beta))', 'independent', 'x', 'dependent', 'y' );
opts = fitoptions( ft );
opts.Display = 'Off';
opts.Lower = [-Inf 0 0];
opts.StartPoint = [0.132903481469417 0.762038603323984 0];
opts.Upper = [Inf 1 1];
[fitresult, gof] = fit( xData, yData, ft, opts );
subplot(5,1,5)
h = plot( fitresult, xData, yData ); title('Second Half')
legend( h, 'responses vs. sample positions', 'fit', 'Location', 'NorthEast' );
% Label axes
xlabel( 'stimulus intensity' );
ylabel( 'Probability of correct response' );
grid on