matlab: 为什么我的程序中for循环只执行了一次? 谢谢A = work_3(nmat); %多行两列的矩阵 A_1 = A(:,1); A_2 = A(:,2); s1 = length(unique(A_2)); count = hist(A_2,unique(A_2)); p = 1; k = 1; q = count(1); D = work_5(A_1,p,q); for j =
来源:学生作业帮助网 编辑:六六作业网 时间:2024/11/06 05:48:21
matlab: 为什么我的程序中for循环只执行了一次? 谢谢A = work_3(nmat); %多行两列的矩阵 A_1 = A(:,1); A_2 = A(:,2); s1 = length(unique(A_2)); count = hist(A_2,unique(A_2)); p = 1; k = 1; q = count(1); D = work_5(A_1,p,q); for j =
matlab: 为什么我的程序中for循环只执行了一次? 谢谢
A = work_3(nmat); %多行两列的矩阵 A_1 = A(:,1); A_2 = A(:,2); s1 = length(unique(A_2)); count = hist(A_2,unique(A_2)); p = 1; k = 1; q = count(1); D = work_5(A_1,p,q); for j = 1:s1-1 if (length(D) >= 3) output = D; sprintf('%4d',output); D = []; p = k + count(j); q = q + count(j+1); D = work_5(A_1,p,q); k = p; else p = p; q = q + count(j+1); D = []; D = work_5(A_1,p,q); k = k + count(j); end
matlab: 为什么我的程序中for循环只执行了一次? 谢谢A = work_3(nmat); %多行两列的矩阵 A_1 = A(:,1); A_2 = A(:,2); s1 = length(unique(A_2)); count = hist(A_2,unique(A_2)); p = 1; k = 1; q = count(1); D = work_5(A_1,p,q); for j =
试一下我的修改:
work_3(nmat); %多行两列的矩阵
A_1 = A(:,1);
A_2 = A(:,2);
s1 = numel(unique(A_2)); % length(unique(A_2));
count = hist(A_2,unique(A_2));
p = 1; k = 1; q = count(1);
D = work_5(A_1,p,q);
for j = 1:(s1-1)
if (length(D) >= 3)
output = D;
sprintf('%4d',output);
D = [];
p = k + count(j);
q = q + count(j+1);
D = work_5(A_1,p,q);
k = p;
else p = p; q = q + count(j+1);
D = [];
D = work_5(A_1,p,q);
k = k + count(j);
end
end