too many input arguments
Show older comments
when running the following code I get the error too many input arguments:
function fireButtonPushed(app)
app.k=app.rowtostrikefield.Value
app.h=app.columntostrikefield.Value
q=randi(10);
w=randi(10);
if app.CPgrid(k,h)==1
app.PlayerTrackingGrid.Data(strike)=1;
app.resulttext.Text='Good Strike'
else app.resulttext.Text='Missed Strike'
end
if app.PlayerMainGrid.Data(q,w)==1
app.CTgrid(q,w)=1;
app.resulttext.Text='You have been hit'
else app.resulttext.Text='They have missed'
end
c=app.PlayerMainGrid.Data
t=app.CPgrid
f = @(t) sum(~t(:));
u= @(c) sum(~c(:));
if f(t)==100
app.resulttext.Text='Player wins'
end
if u(c)==100
app.resulttext.Text='Computer wins'
end
end
I've made properties which contain these variables but I still keep getting the too many input argument error.
properties (Access = private)
CPgrid= zeros(10)
CTgrid= zeros(10)
PlayerMainGrid matlab.ui.control.Table
PlayerTrackingGrid matlab.ui.control.Table
rowtostrikefield matlab.ui.control.NumericEditField
columntostrikefield matlab.ui.control.NumericEditField
resulttext matlab.ui.control.TextArea
fireButton matlab.ui.control.Button
k=0
h=0
MainGridLabel matlab.ui.control.Label
TrackingGridLabel matlab.ui.control.Label
rowlabel matlab.ui.control.Label
columnlabel matlab.ui.control.Label
Positiontostrikelabel matlab.ui.control.Label
end
2 Comments
Jan
on 23 Apr 2022
Please post a copy of the complete error message. This would offer the information, which line is failing.
Why do you define two identical functions:
f = @(t) sum(~t(:));
u = @(c) sum(~c(:));
f(x) and u(x) are exactly the same. It does not matter, how the locally used variable is called.
Abdullahi Omar
on 23 Apr 2022
Answers (0)
Categories
Find more on Image Arithmetic in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!