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
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
Abdullahi Omar 2022년 4월 23일
Thanks but I've managed to get it to work.

댓글을 달려면 로그인하십시오.

답변 (0개)

제품

릴리스

R2021b

태그

질문:

2022년 4월 23일

댓글:

2022년 4월 23일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by