I wrote a script that reads data from the internet and predicts the winner of a football game. The model I use assigns a total of 10 points to each team, so the closest win is 6-4 or a 5-5 draw. I display the winner of the game in the GUI with a text box with the code,
if true % code
if TeamAScore > TeamBScore set(handles.text4,'String', TeamAName);else set(handles.text4,'String', TeamBName);end; end
This works great, but I wanted to spruce it up by letting the user know how big the win is. So I wrote,
if true%Display winner
WinBig = ' wins big.';WinComfort = ' wins comfortably';WinClose = ' wins close';if TeamAScore >= 9 disp(TeamAName); %win big
NewName = [TeamAName, WinBig]; set(handles.text4,'String', NewName);elseif TeamAScore == 8 || 7 disp(TeamAName); % comfortable win
NewName = [TeamAName, WinComfort]; set(handles.text4,'String', NewName);elseif TeamAScore == 6 disp(TeamAName); % close win
NewName = [TeamAName, WinClose]; set(handles.text4,'String', NewName);elseif TeamBScore >=9 disp(TeamBName); % win big
NewNameB = [TeamBName, WinBig]; set(handles.text4,'String', NewNameB);elseif TeamBScore == 8 || 7 disp(TeamBName); % comfortable win NewNameB = [TeamBName, WinComfort]; set(handles.text4,'String', NewNameB);elseif TeamBScore == 6 disp(TeamBName); % close win NewNameB = [TeamBName, WinClose]; set(handles.text4,'String', NewNameB);elseif TeamBScore == TeamAScore disp('Too close to call'); % too close to call
set(handles.text4,'String', 'Too close to call');end; % code end
But this gives me TeamA everytime, not sure why. Any help is appreciated.
Best Answer