Hi, I am new to Matlab and trying to program a hangman game. I found this code on the internet as an example (it is not mine and I don't take credit for it at all, I'm just trying it out to see if I understand it) but there is an error in the code that says there are not enough input arguments in line 97, where I start my "if" statement t == 6. Can someone help me understand why this occurs and what I can do to have it run? I'm hoping this will be a good example for me to be able to understand how to start my own program. Thank you so much in advance!
function[]=gameboard(t)
words = {'electricity', 'donkey', 'hardware', 'xerox', 'transistor', 'computer', 'desktop'...
'engineering', 'hangman', 'circuit', 'imagination', 'robot', 'memory', 'power', 'recursion'...
'submarine', 'chess', 'resistance', 'matrix', 'function', 'laser', 'mechanism', 'telephone'...
'bodyguard', 'titanic', 'global', 'ozone', 'bridge', 'technology', 'spider', 'universe'...
'pyramid', 'sphere', 'member', 'warning', 'yourself', 'screen', 'language', 'elevator'...
'system', 'internet', 'parameter', 'traffic', 'network', 'filter', 'nucleus', 'result'...
'automatic', 'microphone', 'cassette', 'operation', 'country', 'beautiful', 'mission'...
'picture', 'teacher', 'superman', 'undertaker', 'alarm', 'process', 'keyboard', 'poetry'...
'electron', 'certificate', 'grandfather', 'landmark', 'relativity', 'eraser', 'amplifier'...
'design', 'football', 'human', 'musician', 'egyptian', 'elephant', 'queen', 'reception'...
'message', 'wallpaper', 'nationality', 'answer', 'wrong', 'statement', 'forest', 'dolphin'...
'puzzle', 'voltage', 'current', 'mathematics', 'wisdom', 'dream', 'supermarket', 'notebook'...
'database', 'collection', 'barrier', 'project', 'sunlight', 'figure', 'graph', 'orange'...
'battle', 'hundred', 'signal', 'thousand', 'transformation', 'daughter', 'flower', 'knife'...
'communication', 'microwave', 'electronic', 'peace', 'wireless', 'delete', 'window'...
'brain', 'control', 'prophet', 'freedom', 'harbour', 'confidence', 'positive', 'husband'...
'harvest', 'hunger', 'woman', 'children', 'stranger', 'garden', 'pleasure', 'laughter'...
'between', 'recognition', 'tomorrow', 'autumn', 'monkey', 'spring', 'winter', 'misfortune'...
'classification', 'typewriter', 'success', 'difference', 'acoustics', 'astronomy', 'train'...
'agreement', 'sorrow', 'christmas', 'silver', 'birthday', 'championship', 'friendship'...
'comfortable', 'diffusion', 'murder', 'policeman', 'science', 'desert', 'basketball'...
'blood', 'funeral', 'silence', 'garment', 'merchant', 'spirit', 'punishment', 'stone'...
'measurement', 'ocean', 'digital', 'illusion', 'tyrant', 'castle', 'passion', 'physician'...
'magician', 'remedy', 'knowledge', 'threshold', 'number', 'vision', 'expectation', 'fluid'...
'absence', 'mystery', 'morning', 'device', 'thoughts', 'spirit', 'future', 'impossible'...
'mountain', 'treasure', 'machine', 'whispering', 'eternity', 'reflection', 'occupation'...
'achievement', 'lightning', 'secret', 'environment', 'shepherd', 'confusion', 'expansion'...
'grave', 'promise', 'honour', 'reward', 'temple', 'distance', 'eagle', 'saturn', 'grass'...
'finger', 'belief', 'crystal', 'fashion', 'direction', 'captain', 'moment', 'improvement'...
'permission', 'logic', 'analysis', 'password', 'english', 'equalizer', 'simulation'...
'emotion', 'battle', 'expression', 'scissors', 'trousers', 'glasses', 'department', 'creation'...
'dictionary', 'chemistry', 'induction', 'detail', 'widow', 'wealth', 'health', 'faculty'...
'disaster', 'volcano', 'poverty', 'limitation', 'perfect', 'intelligence', 'infinite'...
'failure', 'ignorance', 'destination', 'source', 'resort', 'satisfaction', 'example', 'night'...
'frequency', 'selection', 'substitution', 'kingdom', 'pattern', 'management', 'experience'...
'situation', 'multiply', 'treatment', 'dollar', 'intuition', 'chapter', 'magnet', 'miracle'...
'desire', 'command', 'action', 'consciousness', 'enemy', 'security', 'object', 'realization'...
'happen', 'happiness', 'worry', 'method', 'tolerance', 'error', 'hesitation', 'register'...
'record', 'tongue', 'supply', 'vibration', 'stress', 'despair', 'restaurant', 'month', 'never'...
'television', 'video', 'audio', 'layer', 'mixture', 'doorbell', 'cousin', 'beard', 'corner'...
'finance', 'production', 'invisible', 'excitement', 'afternoon', 'office', 'alphabet', 'certain'...
'illustration', 'valley', 'apartment', 'necessary', 'shortage', 'almost', 'furniture'...
'blanket', 'suggestion', 'overflow', 'demonstration', 'challenge', 'compact', 'kitchen'...
'tower', 'question', 'problem', 'pressure', 'beast', 'encouragement', 'afraid', 'giant'...
'cavity', 'appearance', 'wonderful', 'matter', 'dimension', 'business', 'doubt', 'minute'...
'conversation', 'reaction', 'psychology', 'superstition', 'smash', 'horseshoe', 'change'...
'surprise', 'nothing', 'ladder', 'opposite', 'reality', 'genius', 'string', 'disease'...
'destruction', 'expensive', 'painting', 'chicken', 'wishing', 'profession', 'engagement'...
'hatred', 'possession', 'criticism', 'zebra', 'harmony', 'personality', 'overcome', 'defeat'...
'addition', 'subtraction', 'cipher', 'encryption', 'compression', 'extension', 'towards'...
'blessing', 'meeting', 'difficulty', 'weapon', 'against', 'external', 'internal', 'absolute'...
'legend', 'servant', 'secondary', 'license', 'directory', 'statistics', 'generator', 'motor'...
'attraction', 'sensitivity', 'magnification', 'someone', 'symptom', 'recipe', 'muscle'...
'service', 'family', 'island', 'planet', 'butterfly', 'diving', 'strength', 'missile', 'stream'...
'extreme', 'opportunity', 'illumination', 'cable', 'conflict', 'interference', 'anxiety'...
'receiver', 'transmitter', 'channel', 'company', 'grocery', 'devil', 'angel', 'angle', 'ellipse'...
'exactly', 'document', 'tutorial', 'sound', 'voice', 'abbreviation', 'abdomen', 'abort'...
'abrupt', 'absolute', 'absorption', 'abstract', 'academy', 'acceleration', 'accessory'...
'accident', 'account', 'acidification', 'actress', 'adaptation', 'addiction', 'address'...
'adjustment', 'admiration', 'adoption', 'advanced', 'adventure', 'advertisement', 'aeroplane'...
'agenda', 'airport', 'algorithm', 'allocation', 'aluminium', 'ambiguity', 'ambition', 'ammeter'...
'amphibian', 'anaesthesia', 'analogy', 'anchor', 'animation', 'anode', 'cathode', 'antibiotic'...
'apparent', 'appendix', 'approval', 'approximation', 'arbitrary', 'architecture', 'argument'...
'arithmetic', 'arrangement', 'article', 'ascending', 'ashamed', 'asleep', 'assassination'...
'assembly', 'astonishment', 'atmosphere', 'awful', 'bachelor', 'backbone', 'background'...
'bacteria', 'balance', 'balloon', 'banana', 'barbecue', 'baseball', 'beaker', 'bedroom'...
'beggar', 'behaviour', 'benefit', 'bidirectional', 'biology', 'blackboard', 'blackmail'...
'bladder', 'bleeding', 'blender', 'bonus', 'bottle', 'bracket', 'branch', 'brilliant', 'brown'...
'bubble', 'bucket', 'budget', 'bullet', 'burglar', 'butcher', 'bypass', 'cafeteria', 'calendar'...
'calculator', 'calibration', 'campaign', 'cancellation', 'candidate', 'candle', 'capacitor'...
'carpenter', 'carriage', 'cartoon', 'cascade', 'casual', 'catalyst', 'category', 'celebration'...
'cement', 'ceremony', 'chairman', 'checkout', 'chimney', 'chocolate', 'cigarette', 'church'...
'circumference', 'civilization', 'classroom', 'clearance', 'client', 'coconut', 'coffee'...
'coincidence', 'colleague', 'comfortable', 'competition', 'kangaroo', 'kidnap', 'junction'...
'journal', 'jockey', 'iteration', 'isometric', 'isolation', 'invitation', 'intersection'...
'institution', 'injection', 'humanity', 'housekeeper', 'history', 'heaven', 'guitar', 'guilt'...
'greenhouse', 'glory', 'foundation', 'formula', 'fluctuation', 'fiction', 'extraordinary'...
'emission', 'elasticity', 'earthquake', 'dynamic', 'doctorate', 'divorce', 'derivation'...
'nightmare', 'virtue', 'description'};
axis off
a=[0,20];
b=[0,0];
c=[3,3];
d=[0,14];
e=[3,10];
f=[14,14];
g=[10,10];
h=[14,12];
figure(1)
line(a,b);
line(c,d);
line(e,f);
line(g,h);
hold on;
if t == 6
xc=10;
yc=11;
r=1;
pie=0:0.01:2*pi;
xpts=r*cos(pie)+xc;
ypts=r*sin(pie)+yc;
figure(1)
plot(xpts,ypts);
end
if t == 5
line([10,10],[10,7]);
end
if t == 4
line([10,8],[7,6]);
end
if t == 3
line([10,12], [7,6]);
end
if t == 2
line([10,8],[8,9]);
end
if t == 1
line([10,12],[8,9]);
end
spaces=length(words);
wpos=randi(spaces);
guess=char(words(wpos));
L=length(guess);
k - 1:L;
listword(k) = '*';
listword;
t=7;
aguess=[];
tc=0;
if t > 0
for j=1:26
gameboard(t)
N(j)=input('guess a letter: ','s');
[x]=ismember(guess,N(j));
[y]=ismember(aguess,N(j));
if sum(y)==0
tc=tc+1;
aguess{tc}=N(j);
disp('used letters:');
aguess;
else
t=t+1;
disp('you already guess that letter!!');
end
if sum(x)~=0
listword(x)=N(j);
listword;
tt=sum(listword=='*');
if tt == 0
fprintf('good work')
break
end
else
t=t-1;
if t == 0
fprintf('better luck next time!!')
guess;
break
end
end
end
end