[y1,fs1]=audioread('C:\pic\correct.wav');
[y2,fs2]=audioread('C:\pic\wrong.wav');
loop=1;
while loop==1
photo = imshow('C:\pic\s.jpg');
pause(2);
q1=randsrc(1,1,0:9);
q2=randsrc(1,1,0:9);
q3=randsrc(1,1,10:12);
switch q3
case 10
ans= q1+q2;
case 11
ans= q1-q2;
case 12
ans= q1*q2;
end
first=0;
last=0;
photo = subplot(1,4,1),imshow(sprintf('C:\\pic\\%d.png',q1));
photo = subplot(1,4,2),imshow(sprintf('C:\\pic\\%d.png',q3));
photo = subplot(1,4,3),imshow(sprintf('C:\\pic\\%d.png',q2));
photo = subplot(1,4,4),imshow('C:\pic\13.png');
pause(2)
clf
if ans>=0
subplot(1,3,1),imshow('C:\pic\10.png');
subplot(1,3,3),imshow('C:\pic\0.png');
elseif ans<0
subplot(1,3,1),imshow('C:\pic\11.png');
subplot(1,3,3),imshow('C:\pic\0.png');
end
flag=1;
while flag==1
clear m;
m = mobiledev;
m.Logging=1;
pause(1)
m.Logging=0;
[ac,tac] = accellog(m);
[o, t] = orientlog(m);
x = ac(:,1);
x = max(x);
y = ac(:,2);
y = max(y);
z = o(:,3);
z = max(z);
if z<-100
flag=0;
elseif z<-50&&ans>=0
clf
subplot(1,3,1),imshow('C:\pic\10.png');
subplot(1,3,3),imshow('C:\pic\0.png');
first=0;
last=0;
elseif z<-50&&ans<0
clf
subplot(1,3,1),imshow('C:\pic\11.png');
subplot(1,3,3),imshow('C:\pic\0.png');
first=0;
last=0;
end
if x>=15
last=last+1;
photo = subplot(1,3,3),imshow(sprintf('C:\\pic\\%d.png',last));
end
if y>=20
first=first+1;
photo = subplot(1,3,2),imshow(sprintf('C:\\pic\\%d.png',first));
end
end
clf
if abs(first*10+last)==abs(ans)
sound(y1,fs1);
imshow('C:\pic\o.png');
else
imshow('C:\pic\x.png');
sound(y2,fs2);
end
pause(2)
imshow('C:\pic\again.jpg');
clear m;
m = mobiledev;
m.Logging=1;
pause(4)
m.Logging=0;
[ac,tac] = accellog(m);
x = ac(:,1);
x = max(x);
if x>=15
loop=1;
else
loop=0;
close all
end
end