Function gram "Not enough input arguments"

1 回表示 (過去 30 日間)
Anis BEN JABALLAH
Anis BEN JABALLAH 2018 年 12 月 24 日
編集済み: madhan ravi 2018 年 12 月 24 日
The error i keep having is : "not enough input arguments",i don't why i keep getting it, it has all the informations it needs. Here is the code :
function [resultat]= gram(T,nom_function,varargin)
if strcmp(nom_function,'poly')
for indiv1=1:length(T)
for indiv2=1:length(T)
if indiv2<=indiv1
Y=T(indiv2,:)
X=T(indiv1,:)
C=varargin{1}
H=varargin{2}
resultat(indiv1,indiv2)= polynome(X,Y,C,H)
end
end
end
end
end
and here is the code for the function polynome :
function [resultat]= polynome(X,Y,C,H)
resultat=((X*Y')+C)^H
end
With the table T, it has the information for X and Y, and then i juste have to add for the indiviual C and H. So in order to make the command i just type : gram(T,polynome,2,2). Please can someone explain to me how to fix it.
PS: this is a partial of the code, but the solution to fix it here will help fix the other parts.
  1 件のコメント
madhan ravi
madhan ravi 2018 年 12 月 24 日
編集済み: madhan ravi 2018 年 12 月 24 日
Next time, format the code by pressing the code button by pressing the code button.

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

採用された回答

madhan ravi
madhan ravi 2018 年 12 月 24 日
編集済み: madhan ravi 2018 年 12 月 24 日
Note: In case if you didn't notice there is already a function named gram() so rename your function.
Final_result = gram(T,'poly',2,2) % right calling of your function
if strcmp(nom_function,'poly')==1 % change your line to this
  2 件のコメント
Anis BEN JABALLAH
Anis BEN JABALLAH 2018 年 12 月 24 日
Thank you for your answer, yes it does work. but i don't understand why,
the command strcmp is made to compare things, so if i make strcmp(nom_function,'poly')
what it shoud do is compare the nom of the function to whatever i write, so i write : gram(T,polynomiale,2,2), it should work because there is the word 'poly' in polynomiale.
second question, why add "==1" in strcmp(nom_function,'poly') ?
madhan ravi
madhan ravi 2018 年 12 月 24 日
編集済み: madhan ravi 2018 年 12 月 24 日
Anytime :)
doc strcmp % read it , it returns a logical answer
Plus if my answer works according to what you expect please accept the answer else let know.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeData Import from MATLAB についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by