我有一个 Matlab 代码,你可以在这里看到:
function IWDalg(similarityMatrix,NumberOfSentencesInFile,NumberOfSentencesInAbstract)
NumIWDs = str2int(NumberOfSentencesInFile);
Numnodes=NumIWDs;
av = 1; bv = 0.01; cv = 1;
as = 1; bs = 0.01; cs = 1;
soil = repmat(InitSoil,Numnodes,Numnodes);
for i =1:NumIWDs
IWD{i}.vel = InitVel;
IWD{i}.tour = [];
IWD{i}.tour(1) =i;
IWD{i}.soil = 0;
end
我在matlab尝试编译 For子句的第一行时的循环我得到了这个错误:
??? For colon operator with char operands, first and last operands must be char.
我是matlab编程的初学者。
祝你好运
答案 0 :(得分:2)
试试这个。
NumIWDs = str2double(NumberOfSentencesInFile);
您应该将 char 转换为 double 以执行冒号。