Labfans是一个针对大学生、工程师和科研工作者的技术社区。 | 论坛首页 | 联系我们(Contact Us) |
![]() |
|
![]() |
#1 |
初级会员
注册日期: 2009-01-16
住址: 北京
年龄: 37
帖子: 20
声望力: 17 ![]() |
![]()
比如一个4*3的矩阵,对他的行做全排列,得到A44共24个矩阵。
请大家帮忙!!! |
![]() |
![]() |
![]() |
#2 |
初级会员
注册日期: 2009-01-16
住址: 北京
年龄: 37
帖子: 20
声望力: 17 ![]() |
![]()
有人会么?
我用循环做了一个,好麻烦啊 谁会简单一点的? |
![]() |
![]() |
![]() |
#3 |
初级会员
注册日期: 2009-03-17
年龄: 39
帖子: 18
声望力: 17 ![]() |
![]()
离散数学上有。
这是我以前编的,你改改用。 function allPerm = getAllPermutation(iNUM) firstPerm = [1:iNUM]; endPerm = [iNUM:-1:1]; rowPerm = prod([1:iNUM]); curID = 1; try allPerm = zeros(rowPerm,iNUM); catch error('Can''t creat so much permutation'); end while ~isequal(firstPerm,endPerm) allPerm(curID, ![]() firstPerm = getNextPerm(firstPerm); curID = curID + 1; end allPerm(curID, ![]() function nextPermutation=getNextPerm(curPermutation) % getNextPerm: % get next permutation use method from P288 in % [Discrete Mathematics and Its Applications(4th)] lenP = length(curPermutation); j = lenP - 1; nextPermutation = curPermutation; while nextPermutation(j) > nextPermutation(j+1) j = j - 1; % j 是使得a(j)<a(j+1)的最大下标 end k = lenP; while nextPermutation(j) > nextPermutation(k) k = k - 1; % a(k) 是在a(j)右边大于a(j)的最小整数 end % change a(k) , a(j) temp= nextPermutation(j); nextPermutation(j) = nextPermutation(k); nextPermutation(k) = temp; % 把j位以后的排序尾部按递增顺序排列 r = lenP; s = j + 1; while r > s % change a(r) , a(s) temp = nextPermutation(r); nextPermutation(r) = nextPermutation(s); nextPermutation(s) = temp; r = r - 1; s = s + 1; end |
![]() |
![]() |
![]() |
主题工具 | |
显示模式 | |
|
|
![]() |
||||
主题 | 主题作者 | 版面 | 回复 | 最后发表 |
[MATLAB基础] 如何实现三维曲面与一个平面共存? | chen_feng0312 | MATLAB论坛 | 2 | 2009-05-14 15:25 |
[MATLAB混合编程] 【求助】求矩阵的LU分解的L和U 并验证正确性 | dhsky1984 | MATLAB论坛 | 2 | 2009-05-10 13:04 |
[求助]求高手帮之指点一下高斯曲面拟合算法 | melodious | MATLAB论坛 | 0 | 2009-02-24 14:49 |
fminsearch优化问题[求助] | yue_liang423 | MATLAB论坛 | 0 | 2008-07-01 19:59 |
求cook-torrence模型的matlab源码 | esther0401 | MATLAB论坛 | 0 | 2008-05-19 11:14 |