how to resolve this "not enough input arguments" from the code shown below

1 回表示 (過去 30 日間)
Sai Dinesh Kancharana
Sai Dinesh Kancharana 2019 年 9 月 4 日
コメント済み: Jan 2019 年 9 月 4 日
here objFun=@(mag)summ;
i.e it summ is given as a function handle to objFun, and that objFun is called from the PSO.m file.
The X(:,idx) is a column vector, that is being passed.
I tried debugging it, but i have found that the argument is not being passed, and hence the error "not enough arguments".
In noth the screenshots the part of the errors are marked, please make a not of it.
Any help or suggestions would be greatly appreciated.
Thanks and regard,
K.Sai Dinesh
Screenshot (11).png
Screenshot (10).png
  1 件のコメント
Jan
Jan 2019 年 9 月 4 日
Please post code as text, not as screenshot. Then it is much easier to re-use it to create an answer.

サインインしてコメントする。

回答 (1 件)

Jan
Jan 2019 年 9 月 4 日
編集済み: Jan 2019 年 9 月 4 日
objFun=@(mag)summ
Now calling objFun calls summ without input arguments. I assume, you mean:
objFun = @summ
which is a more efficient version than:
objFun = @(mag) summ(mag)
The code looks strange:
for i = magt(:,1)
if(magt(i)>=0.7)
...
end
end
Now the contents of magt is used as index of the same vector. Are you sure that this is wanted? This looks better:
for i = 1:numel(magt)
...
end
You can omit the loop also:
m = (magt > 0.7);
err1 = sum(abs(magt - 1.004 * m - 0.001))

カテゴリ

Help Center および File ExchangeMatrix Indexing についてさらに検索

タグ

製品


リリース

R2016b

Community Treasure Hunt

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

Start Hunting!

Translated by