Advanced Voting GUI in MATLAB |
- Voters who's names and Id's are present in Database can only vote.
- Duplicate Voting is not allowed.
- Voting Percentage is also calculated.
To create database, Microsoft Excel is used and names of voters and there voting id's are written in two different columns. For this project a sample database of 10 voters is created and is shown in the image given below.
Database of 10 Voters in Excel |
Whenever someone presses the voting button, system will asks for it's voting id (as shown in image below) and then search the voting id in it's database.
Enter Voting ID |
Case 1: If Voter Id exist, the system will greet voter with message "Thank You" as shown below.
Thank You for Voting |
User Not Found |
Multiple Times Voting Not Allowed. |
Voting Results, Party1 is clear Winner :-) |
Download Source From GitHub
There are basically two main parts of the project, one is loading and storing the data and another is using this data to increase the vote count or display messages or error to the voters.
Coming to the first part, i.e loading the Excel file data into MATLAB, this is done using the following piece of code.
Coming to the first part, i.e loading the Excel file data into MATLAB, this is done using the following piece of code.
global party1;
% Open Voter ID List File
filename = 'VotingList.xlsx';
[~, ~, raw] = xlsread(filename);
voters_name = raw(2:end, 2);
voters_id = raw(2:end, 3);
% Create voting status variable to keep track of person's who already voted
voting_status = zeros(numel(voters_name), 1);
Now coming to second and most important part, where decision is made if a voter is a legal voter or not.
global party1;
global voters_name
global voters_id
global voting_status
prompt = {'Enter your Voter ID ?'};
dlg_title = 'Input';
num_lines = 1;
defaultans = {'1234567890'};
answer = inputdlg(prompt,dlg_title,num_lines,defaultans);
index = find([voters_id{:}] == str2double(answer));
if index
%disp (voters_name(index));
name = string(voters_name(index));
if voting_status(index) == 0
party1 = party1+1;
% Voting Done
voting_status(index) = 1;
msgbox(sprintf('Thank you "%s" for voting',name),'Vote Success')
else
msgbox(sprintf('"%s" you cant give vote multiple times', name),'Duplicate')
end
else
errordlg('User Not Found','Database Error');
end
The following video links shows complete demo of this project.
Please contact us in case of any doubt.
Future Possibilities
The above system has limitation, that if someone else remembers your voting ID, then that voter can give your vote, to overcome this situation and make system more interesting, Bio-metric system or finger print scanner can be added to this project, if we get time, we will definitely post this project also.
No comments:
Post a Comment