|
matlab程序为:
clc
clear all
I=3;
J=7;
ii=zeros((I+1)*(J+1),(I+1)*(J+1));
jj=zeros((I+1)*(J+1),(I+1)*(J+1));
i=zeros((I+1)*(J+1),(I+1)*(J+1));
j=zeros((I+1)*(J+1),(I+1)*(J+1));
for iii=1:(I+1)*(J+1)
for jjj=1:(I+1)*(J+1)
jj(iii,jjj)=mod(jjj,J+1)-1; %取模(余)
if jj(iii,jjj)==-1
jj(iii,jjj)=J;
end
j(iii,jjj)=mod(iii,J+1)-1;
if j(iii,jjj)==-1
j(iii,jjj)=J;
end
ii(iii,jjj)=floor((jjj-jj(iii,jjj))/(J+1)); %取整
i(iii,jjj)=floor((iii-j(iii,jjj))/(J+1));
end
end
计算结果分别为(以i为例):
i =
Columns 1 through 13
0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0
1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1 1 1 1
2 2 2 2 2 2 2 2 2 2 2 2 2
2 2 2 2 2 2 2 2 2 2 2 2 2
2 2 2 2 2 2 2 2 2 2 2 2 2
2 2 2 2 2 2 2 2 2 2 2 2 2
2 2 2 2 2 2 2 2 2 2 2 2 2
2 2 2 2 2 2 2 2 2 2 2 2 2
2 2 2 2 2 2 2 2 2 2 2 2 2
2 2 2 2 2 2 2 2 2 2 2 2 2
3 3 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3 3 3 3 3 3 3 3 3 3 3
Columns 27 through 32
0 0 0 0 0 0
0 0 0 0 0 0
0 0 0 0 0 0
0 0 0 0 0 0
0 0 0 0 0 0
0 0 0 0 0 0
0 0 0 0 0 0
0 0 0 0 0 0
1 1 1 1 1 1
1 1 1 1 1 1
1 1 1 1 1 1
1 1 1 1 1 1
1 1 1 1 1 1
1 1 1 1 1 1
1 1 1 1 1 1
1 1 1 1 1 1
2 2 2 2 2 2
2 2 2 2 2 2
2 2 2 2 2 2
2 2 2 2 2 2
2 2 2 2 2 2
2 2 2 2 2 2
2 2 2 2 2 2
2 2 2 2 2 2
3 3 3 3 3 3
3 3 3 3 3 3
3 3 3 3 3 3
3 3 3 3 3 3
3 3 3 3 3 3
3 3 3 3 3 3
3 3 3 3 3 3
3 3 3 3 3 3
按照上面给出的matlab程序,粘贴到matlab命令窗口中运行,即可得到当I=3,J=7时,矩阵i、j、ii、jj的各个元素,四个矩阵都是32*32的矩阵。举例说明,当iii、jjj都取1时,你所说的四个下标的值就分别存储在矩阵i、j、ii、jj的第一行第一列中;当iii取1,jjj为2都时,你所说的四个下标的值就分别存储在矩阵i、j、ii、jj的第一行第二列中;以此类推。计算出来的四个矩阵分别代表四个下标。上面程序计算得到的四个矩阵的结果,可以跟你发的图片结果进行对比,如果一样的话,说明你的程序没有问题。 |
|