MATLAB爱好者论坛-LabFans.com

MATLAB爱好者论坛-LabFans.com (https://www.labfans.com/bbs/index.php)
-   MATLAB论坛 (https://www.labfans.com/bbs/forumdisplay.php?f=6)
-   -   [MATLAB基础] 程序出错 求救 (https://www.labfans.com/bbs/showthread.php?t=7712)

8wy4993938 2009-04-15 15:38

程序出错 求救
 
x=rand(400,1024)
for n=1:1:40;
a=randperm(10)+10*(n-1);
c=((10*n-9):10*n)
a(:,[3:10])=[]
for i=1:1:10
j=1:1:10
a(1)=c(i)
a(2)=c(i)
end
x(a(1),:)=[]
x(a(2),:)=[]
end
disp(x)
从随机矩阵X中从1到400,按顺序每10行中随机抽取两行
将抽取掉的行数产生一个新的矩阵
将剩下的行数成矩阵

silas_xue 2009-04-16 05:26

回复: 程序出错 求救
 
lz 请问是完整代码么? 能否把MatlAB错误说明的整句英文说明也贴出来
大家一起讨论一下

TTT_IOU 2009-04-17 14:33

回复: 程序出错 求救
 
不知下程序可否:
k=input('please input a random number from 1 to 10:');
l=input('please input a random number from 1 to 10:');
tic
x=rand(400,1024);
y=zeros(80,1024);
for n=1:40
b=randperm(10);
a(2*n-1)=(n-1)*10+b(k);
a(2*n)=(n-1)*10+b(l);
y(2*n-1,: )=x(a(2*n-1),: );
y(2*n,: )=x(a(2*n),: );
end
x(a,: )=[];
x,y
toc
不行的话说一声!!不行的话说一声!!


所有时间均为北京时间。现在的时间是 11:58

Powered by vBulletin
版权所有 ©2000 - 2025,Jelsoft Enterprises Ltd.