too many input arguments
显示 更早的评论
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 个评论
Jan
2022-4-23
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
2022-4-23
回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Image Arithmetic 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!