我是新来的MATLAB。我已经使用FOR循环产生的n个数字(3×1)小矩阵。所有矩阵有。现在我要来连接所有值,形成一个大阵'M'请看看我的codeS下面的随机值。
N =输入('请输入审核规定的\数N');
对于k = 1:1:N
fprintf中(请输入%深x%D决策矩阵%d号标准\ N',N,N,K);
米=输入('');
S =总和(米);
对于i = 1:1:N
对于j = 1:1:n的
米(I,J)=米(I,J)/ S(j)条;
结束
结束
RS =总和(米,2);
PK = RS / N;
fprintf中(优先矩阵%d号标准)是:: \ N',K);
DISP(PK);
end`
请输入审核规定的数量
3
请输入3×3的决策矩阵1号标准
[1 2 3; 4 5 6; 7 8 9]
优先矩阵1号标准)是::
0.1278
0.3333
0.5389
请输入3×3的决策矩阵为2号标准
[4 5 6; 3 7 9; 8 1 4]
优先矩阵为无2条件)是::
0.3224
0.4040
0.2736
请输入3×3的决策矩阵3号标准
[1 5 4; 2 7 0; 3 6 7]
优先矩阵没有3标准)是::
0.2694
0.2407
0.4899
M = [0.1278 0.3224 0.2644;
0.3333 0.4040 0.2407;
0.5839 0.2736 0.4899]
很难看到什么是你的循环怎么回事,但这个例子应该有所帮助。矩阵拼接完成用逗号(添加列)或分号(添加行)。所以,如果你有大小1×3的三排阵看起来像:
M1 = [1278 0.3224 0.2644]
M2 = [3338 0.4040 0.2407]
M3 = [5839 0.2736 0.4899]
您可以做一个3×3矩阵M串联的小矩阵的分号:
M = [M1,M2,M3]
这看起来是这样的:
M =
0.12780 0.32240 0.26440
0.33380 0.40400 0.24070
0.58390 0.27360 0.48990
I am a new to MATLAB. I have generated n numbers of smaller matrices of (3 x 1 ) by using a FOR loop. All the matrices are having random values .Now I want to concatenate all the values to form a LARGE matrix 'M'Please check out my codes below .
n= input('please input the number of criterias \n');
for k=1:1:n
fprintf('Please input the %d X %d decision matrix for no %d Criteria \n', n,n,k);
m=input('');
S=sum(m);
for i=1:1:n
for j=1:1:n
m(i,j)= m(i,j)/S(j);
end
end
rS=sum(m,2);
pk=rS/n;
fprintf('the prioritized matrix for no %d criteria ) is ::\n',k);
disp(pk);
end`
please input the number of criterias
3
Please input the 3 X 3 decision matrix for no 1 Criteria
[1 2 3 ; 4 5 6; 7 8 9]
the prioritized matrix for no 1 criteria ) is ::
0.1278
0.3333
0.5389
Please input the 3 X 3 decision matrix for no 2 Criteria
[4 5 6; 3 7 9; 8 1 4]
the prioritized matrix for no 2 criteria ) is ::
0.3224
0.4040
0.2736
Please input the 3 X 3 decision matrix for no 3 Criteria
[1 5 4 ; 2 7 0; 3 6 7]
the prioritized matrix for no 3 criteria ) is ::
0.2694
0.2407
0.4899
M = [ .1278 .3224 .2644 ;
.3333 .4040 .2407 ;
.5839 .2736 .4899 ]
Hard to see what is going on with your loops, but this example should help. Matrix concatenation is done with commas (to add columns) or semi-colons (to add rows). So if you have three row matrices of size 1x3 that look like:
m1=[.1278 .3224 .2644]
m2=[.3338 .4040 .2407]
m3=[.5839 .2736 .4899]
you can make a 3x3 matrix M concatenating your small matrices with semi-colons:
M=[m1;m2;m3]
that looks like this:
M =
0.12780 0.32240 0.26440
0.33380 0.40400 0.24070
0.58390 0.27360 0.48990