Transpose single column onto a Geometry
1 次查看(过去 30 天)
显示 更早的评论
Hi, I have (26 x 1) W = 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46, and want to use X(26 x 2) which is the address matrix for G...
X =
2 2
3 2
4 2
2 3
3 3
4 3
2 4
3 4
4 4
2 5
3 5
4 5
2 6
3 6
4 6
2 7
3 7
4 7
2 8
3 8
4 8
2 9
3 9
4 9
2 10
3 10,
to transpose W onto: G =
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1
-1 0 0 0 0 0 0 0 0 0
-1 0 0 0 0 0 0 0 0 0
-1 0 0 0 0 0 0 0 0 5
0 个评论
采纳的回答
Star Strider
2016-5-13
%Matrix size
columns=10;
rows=4;
%Blank matrix
X = zeros(4,10);
%Fill matrix (1st row & first column)
newrow =-ones(1,columns); % the row to replace row 1 with
newcolumn=-ones(rows,1); % the column to replace column 1 with
X(1,:)= newrow ; % replace row 1 in a with new
X(:,1) = newcolumn(:); % replace column 1 in a with new
zi = find(X == 0);
X(zi) = [W; 5]'
X =
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1
-1 21 24 27 30 33 36 39 42 45
-1 22 25 28 31 34 37 40 43 46
-1 23 26 29 32 35 38 41 44 5
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!