function prac2(varargin) % This program was comlpeted by Michael Bellato on Dec 11, 2012. % This program randomly selects a common GRE root word and its meaning from a data file. % It then selects 3 random root meanings. Once the user attempts to match % the root with the correct meaning, the program provides feedback. global wrrt wrmn ex x1 r a1 a2 b1 b2 b3 b4 p6 p7 p8 ac ai ac=imread('180x.jpg'); % load Einstein image ai=imread('180px.jpg'); % load Donkey image randn('seed',sum(100*clock)); rand('seed',sum(100*clock)); if nargin==0 % create GUI intro % Into Welcome i1=uicontrol('style','text','units','normalized',... 'position',[0.25 0.89 0.5 0.1],'string','Welcome to the GRE Word Root Tutorial','fontsize',16,... 'fontweight','bold','foregroundc','w','backgroundc','b'); pc=uicontrol('style','text','units','normalized',... % instructions 'position',[0.1 0.5 0.7 0.2],'string',... 'You will be presented a word root in a black text box. These roots come from the 240 most common word roots found on the GRE. There will be 4 possible answers, only one of which is a correct match. If your answer is incorrect, the background will turn red. Once you find the correct answer the screen will turn green and you will be shown examples that use the specific word root. Click "Begin" to start then "Next" for the next example. Try to avoid the donkey!',... 'fontsize',16,'fontweight','bold','foregroundc','w','backgroundc ','b'); set(1,'menubar','none','name','Welcome','color','w','units','nor malized','pos',[.2 .2 .7 .7]); ie=uicontrol('style','pushbutton','units','normalized',... % Begin 'position',[0.45 0.3 0.1 0.1],'string','Begin','fontsize',16,... 'fontweight','bold','foregroundc','k','backgroundc','g',... 'callback','prac2(''callie'')'); elseif strcmpi(varargin,'callie')==1; close all; % if begin is pressed end if nargin==0 || strcmpi(varargin,'callp7')==1; % randomly generates numbers at onset % of pragram or when the next button is pressed load msu2 % load word roots wrrt = Roots; % save roots in cell x1=randi([2 242],[4 1]); % generate 4 random numbers between 2 and 242 r=randi([1 4]); % generate 1 random number between 1 and 4 a1=wrrt(x1(r)); % assign r (random 1-4) as target root word (wrrt) load msum % load word meanings wrmn = Roots; % save roots in cell % assign 1 random # from x1 [2 242] as word (msum) b1=wrmn(x1(1)); b2=wrmn(x1(2)); b3=wrmn(x1(3)); b4=wrmn(x1(4)); load example ex = Roots; a2=ex(x1(r)); variable % load examples of roots % saves examples in cell % assigns the respective example as a end % displays GUI when the Begin or Next buttons have been pressed if strcmpi(varargin,'callie')==1 | strcmpi(varargin,'callp7')==1; %**************** create pushbutton % Title pa=uicontrol('style','text','units','normalized',... 'position',[0.25 0.89 0.5 0.1],'string','GRE Word root Tutorial','fontsize',16,... 'fontweight','bold','foregroundc','w','backgroundc','b'); % Woord root pb=uicontrol('style','text','units','normalized',... 'position',[0.05 0.75 0.8 0.1],'string',a1,'fontsize',16,... 'fontweight','bold','foregroundc','g','backgroundc','k'); % Meaning 1 p1=uicontrol('style','pushbutton','units','normalized',... 'position',[0.1 0.64 0.4 0.1],'string',b1,'fontsize',16,... 'fontweight','bold','foregroundc','b','backgroundc','w',... 'callback','prac2(''callp1'')'); % Meaning 2 p2=uicontrol('style','pushbutton','units','normalized',... 'position',[0.1 0.53 0.4 0.1],'string',b2,'fontsize',16,... 'fontweight','bold','foregroundc','b','backgroundc','w',... 'callback','prac2(''callp2'')'); % Meaning 3 p3=uicontrol('style','pushbutton','units','normalized',... 'position',[0.1 0.42 0.4 0.1],'string',b3,'fontsize',16,... 'fontweight','bold','foregroundc','b','backgroundc','w',... 'callback','prac2(''callp3'')'); % Meaning 4 p4=uicontrol('style','pushbutton','units','normalized',... 'position',[0.1 0.31 0.4 0.1],'string',b4,'fontsize',16,... 'fontweight','bold','foregroundc','b','backgroundc','w',... 'callback','prac2(''callp4'')'); % Examples Title p5=uicontrol('style','text','units','normalized',... 'position',[0.1 0.17 0.2 0.07],'string','Examples:','fontsize',16,... 'fontweight','bold','foregroundc','k','backgroundc','c'); % Examples p6=uicontrol('style','text','units','normalized',... 'position',[0.1 0.08 0.75 0.1],'string','','fontsize',16,... 'fontweight','bold','foregroundc','k','backgroundc','c',... 'callback','prac2(''callp6'')'); % Next p7=uicontrol('style','pushbutton','units','normalized',... 'position',[0.88 0.03 0.1 0.1],'string','Next','fontsize',16,... 'fontweight','bold','foregroundc','w','backgroundc',[.9 0 .09],... 'callback','prac2(''callp7'')'); % Image p8=uicontrol('style','pushbutton','units','normalized',... 'position',[0.6 0.4 0.3 0.3],'string','Good Luck','fontsize',16,... 'fontweight','bold','foregroundc','k','backgroundc','g',... 'callback','prac2(''callp8'')'); set(1,'menubar','none','name','GRE Verbal Practice','color','w','units','normalized','pos',[.2 .2 .7 .7]); elseif strcmpi(varargin,'callp1')==1; if r==1; set(1,'color','g'); % if the correct answer is selected, based off r set(p6,'string',a2,'fontsize',16,... 'fontweight','bold','foregroundc','k','backgroundc','c'); set(p8,'cdata',ac,'string',''); elseif r~=1; set(1,'color',[.8 0 0]); set(p8,'cdata',ai,'string','NOPE'); end % if the wrong answer is selected, based off r elseif strcmpi(varargin,'callp2')==1; if r==2; set(1,'color','g'); % if the correct answer is selected, based off r set(p6,'string',a2,'fontsize',16,... 'fontweight','bold','foregroundc','k','backgroundc','c'); set(p8,'cdata',ac,'string',''); elseif r~=2; set(1,'color',[.83 0 0]); set(p8,'cdata',ai,'string','INCORRECT'); end % if the wrong answer is selected, based off r elseif strcmpi(varargin,'callp3')==1; if r==3; set(1,'color','g'); % if the correct answer is selected, based off r set(p6,'string',a2,'fontsize',16,... 'fontweight','bold','foregroundc','k','backgroundc','c'); set(p8,'cdata',ac,'string',''); elseif r~=3; set(1,'color',[.86 0 0]); set(p8,'cdata',ai,'string','TRY AGAIN'); end % if the wrong answer is selected, based off r elseif strcmpi(varargin,'callp4')==1; if r==4; set(1,'color','g'); set(p6,'string',a2,'fontsize',16,... % if the wrong answer is selected, based off r 'fontweight','bold','foregroundc','k','backgroundc','c'); set(p8,'cdata',ac,'string',''); elseif r~=4; set(1,'color',[.89 0 0]); set(p8,'cdata',ai,'string','WRONG'); end % if the wrong answer is selected, based off r end