Dim arrStim(140), Typecount(3),arrtmp(28) As Integer Dim i, k, flag As Integer Dim bools As Boolean For i = 1 To UBound(arrtmp) If i<21 Then k=1 arrtmp(i)=k Else If i<25 Then k=2 arrtmp(i)=k Else k=3 arrtmp(i)=k End If End If Next For i=1 To 5 Do bools=True RandomizeArray arrtmp,1,UBound(arrtmp) If i<>1 And i<>5 Then If arrtmp(1)=2 Or arrtmp(1)=3 Then If arrtmp(1)=flag Then bools=False Else For k=1 To 27 If arrtmp(k)=2 Or arrtmp(k)=3 Then If arrtmp(k)=arrtmp(k+1) Then bools=False Exit For End If End If Next End If Else For k=1 To 27 If arrtmp(k)=2 Or arrtmp(k)=3 Then If arrtmp(k)=arrtmp(k+1) Then bools=False Exit For End If End If Next End If ElseIf i=1 Then If arrtmp(1)=2 Or arrtmp(1)=3 Or arrtmp(2)=2 Or arrtmp(2)=3 Then bools=False Else For k=1 To 27 If arrtmp(k)=2 Or arrtmp(k)=3 Then If arrtmp(k)=arrtmp(k+1) Then bools=False Exit For End If End If Next End If ElseIf i=5 Then If arrtmp(27)=2 Or arrtmp(27)=3 Or arrtmp(28)=2 Or arrtmp(28)=3 Then bools=False ElseIf arrtmp(1)=2 Or arrtmp(1)=3 Then If arrtmp(1)=flag Then bools=False Else For k=1 To 27 If arrtmp(k)=2 Or arrtmp(k)=3 Then If arrtmp(k)=arrtmp(k+1) Then bools=False Exit For End If End If Next End If Else For k=1 To 27 If arrtmp(k)=2 Or arrtmp(k)=3 Then If arrtmp(k)=arrtmp(k+1) Then bools=False Exit For End If End If Next End If End If Loop Until bools=True For k=1 To 28 arrStim((i-1)*28+k)=arrtmp(k) Next flag=arrtmp(28) Next For i=1 To UBound(arrStim) TrialList.SetNested CStr(i), "list" & arrStim(i) Next TrialList.Reset 要求:有三种实验材料,A材料100个、BC材料各20个。BC不能呈现在首尾的前后两个刺激上。BC同种材料不能重复呈现,BC可以挨着呈现。对A材料不反应,反应位错;对B材料按“f”键进行反应,C材料按“j”键进行反应。实验过程为:注视点800毫秒→刺激界面(无限时间) →反馈界面。设计要求: 1)请用“化整为零+随机打乱判断”法进行设计。 对以上编码进行分析后改成一个新的编码
时间: 2023-12-12 16:04:55 浏览: 56
一个ASP中的数组
Dim arrStim(140), Typecount(3), arrtmp(28) As Integer
Dim i, k, flag As Integer
Dim bools As Boolean
'将三种材料分别存入数组
Dim arrA(100) As Integer
For i = 1 To UBound(arrA)
arrA(i) = 1
Next
Dim arrB(20) As Integer
For i = 1 To UBound(arrB)
arrB(i) = 2
Next
Dim arrC(20) As Integer
For i = 1 To UBound(arrC)
arrC(i) = 3
Next
'将三个数组合并为一个大数组
Dim arrABC(140) As Integer
For i = 1 To 100
arrABC(i) = arrA(i)
Next
For i = 101 To 120
arrABC(i) = arrB(i - 100)
Next
For i = 121 To 140
arrABC(i) = arrC(i - 120)
Next
'随机打乱大数组
RandomizeArray arrABC, 1, UBound(arrABC)
'判断BC不能呈现在首尾的前后两个刺激上
For i = 1 To 5
Do
bools = True
RandomizeArray arrtmp, 1, 28
If i <> 1 And i <> 5 Then
If arrtmp(1) = 2 Or arrtmp(1) = 3 Then
If arrtmp(1) = flag Then
bools = False
Else
For k = 1 To 27
If arrtmp(k) = 2 Or arrtmp(k) = 3 Then
If arrtmp(k) = arrtmp(k + 1) Then
bools = False
Exit For
End If
End If
Next
End If
Else
For k = 1 To 27
If arrtmp(k) = 2 Or arrtmp(k) = 3 Then
If arrtmp(k) = arrtmp(k + 1) Then
bools = False
Exit For
End If
End If
Next
End If
ElseIf i = 1 Then
If arrtmp(1) = 2 Or arrtmp(1) = 3 Or arrtmp(2) = 2 Or arrtmp(2) = 3 Then
bools = False
Else
For k = 1 To 27
If arrtmp(k) = 2 Or arrtmp(k) = 3 Then
If arrtmp(k) = arrtmp(k + 1) Then
bools = False
Exit For
End If
End If
Next
End If
ElseIf i = 5 Then
If arrtmp(27) = 2 Or arrtmp(27) = 3 Or arrtmp(28) = 2 Or arrtmp(28) = 3 Then
bools = False
ElseIf arrtmp(1) = 2 Or arrtmp(1) = 3 Then
If arrtmp(1) = flag Then
bools = False
Else
For k = 1 To 27
If arrtmp(k) = 2 Or arrtmp(k) = 3 Then
If arrtmp(k) = arrtmp(k + 1) Then
bools = False
Exit For
End If
End If
Next
End If
Else
For k = 1 To 27
If arrtmp(k) = 2 Or arrtmp(k) = 3 Then
If arrtmp(k) = arrtmp(k + 1) Then
bools = False
Exit For
End If
End If
Next
End If
End If
Loop Until bools = True
'将随机打乱且符合要求的28个刺激加入到总数组中,并记录最后一个刺激的类型
For k = 1 To 28
arrStim((i - 1) * 28 + k) = arrABC((i - 1) * 28 + arrtmp(k))
Next
flag = arrStim(i * 28)
Next
'将刺激数组存入TrialList
For i = 1 To UBound(arrStim)
TrialList.SetNested CStr(i), "list" & arrStim(i)
Next
TrialList.Reset
阅读全文