Error while calling a function a class
이전 댓글 표시
Hi all, Please help. I have a file with the name Bandit.m. It has a class defined Bandit. Code is as follows:
********************
classdef Bandit
properties
m
mean_val
N
end
methods
function self = Bandit(m)
self.m = m;
self.mean_val = 0;
self.N = 0;
end
function reward = pull_arm()
reward = randn() + self.m;
end
end
end
********************
Now, I have another file called test.m in the same directory. I run the following line and get the error. Code is as follows:
a = Bandit(5);
a.pull_arm();
when I run the above code, I get "Too many input arguments.". Am I doing some mistakes in the above 2 lines of code? I have been working with Python, but using MATLAB for the first time.
I am new to MATLAB. Can somebody help?
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Environments에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!