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!