Labfans是一个针对大学生、工程师和科研工作者的技术社区。 | 论坛首页 | 联系我们(Contact Us) |
![]() |
![]() |
#1 |
初级会员
注册日期: 2008-10-08
帖子: 24
声望力: 17 ![]() |
![]()
code如下:
Test = cell(1,40); V = cell(1,40); L = zeros(1,40); Accuracy = zeros(1,40); for i = 1:40 for j = 2:39 Test_i = find(TestLabel(:)==i); V_i = length(Test_i); eval(['Test',num2str(i),' = Test_i ;']); Test{i} = eval(['Test' num2str(i)]); eval(['V',num2str(i),' = V_i ;']); V{i} = eval(['V' num2str(i)]); L(1) = V{1}; cTestLabel = knnclassify(TestFeature, TrainFeature, TrainLabel); Accuracy(1) = sum(cTestLabel(1:V{1})==TestLabel(1:V{1}))./V{1}; L(j) = L(j-1) + V{j}; Accuracy(j) = sum(cTestLabel(L(j-1)+1:L(j))==TestLabel(L(j-1)+1:L(j)))./V{j}; end end 前面运行的没有问题,V的结果是正确的。但运行到了L(j) 和Accuracy(j)时,总显示错误信息:??? In an assignment A(I) = B, the number of elements in B and I must be the same. 在command window里逐步算L(2), L(3),...却不会有问题。 求救啊!!!:mad:
__________________
:ft: |
![]() |
![]() |