How can you create a metric using ones, zeros, eye
2 views (last 30 days)
Show older comments
I would like to create matrix
3 0 0 4 4 0
0 3 0 4 4 0
1 1 3 4 4 0
1 1 2 2 2 2
I am stuck after A=zeros(4,6)
0 Comments
Accepted Answer
KALYAN ACHARJYA
on 15 Oct 2018
Edited: KALYAN ACHARJYA
on 15 Oct 2018
Just manual you can do that, as I don't find the relationships between elements. apart from just in the second row, 1 position shifting in 1st row
A=zeros(4,6);
A(1,:)=[3 0 0 4 4 0];
A(2,:)=[0 3 0 4 4 0];
A(3,:)=[1 1 3 4 4 0];
A(4,:)=[1 1 2 2 2 2];
A =
3 0 0 4 4 0
0 3 0 4 4 0
1 1 3 4 4 0
1 1 2 2 2 2
0 Comments
More Answers (1)
Steven Lord
on 15 Oct 2018
So you've created an A matrix of the correct size, but without the elements filled in. Now create matrices that represent the data that should be stored in A and use subscripted assignment to put those pieces in the right place in A.
For example, if A is a 5-by-5 array you can make the intersections of rows 2 through 4 and columns 1, 3, and 5 of A each equal to 3 this way:
A = zeros(5, 5)
B = 3*ones(3)
A(2:4, [1 3 5]) = B
Use this technique to put your four puzzle pieces into A. Two of them overlap, so you need to be careful about the order in which you insert those pieces.
0 Comments
See Also
Categories
Find more on Resizing and Reshaping Matrices in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!