From the given matrix(6 X 4) how to form a new matrix (12 X 10)
1 view (last 30 days)
Show older comments
From the given matrix how to form a new matrix.
For example I have a matrix (6 x 4) and I have to form a matrix of (12 x 10)
Given Matrix B = [
1 2 0.0281 35.587
1 4 0.0304 33.222
1 5 0.0064 156.25
2 3 0.0108 92.592
3 4 0.0297 37.670
4 5 0.0297 37.670
];
From the above matrix (b) i have to take the values of column 4 only
Answer should be =
A =
The colours shows in the matrix are the same value rather you can say a matrix of (2x2) in which diagonal elements are +ve and offdiagonal are –ve
for i=1:12
for j=1:10
for k=1:6
%----------------------------------------------%
if i==1 && j==1 && k==1
A(i,j+5)=B(k,4)
end
if i==1 && j==2 && k==1
A(i,j+5)=-B(k,4)
end
if i==2 && j==1 && k==1
A(i,j+5)=-B(k,4)
end
if i==2 && j==2 && k==1
A(i,j+5)=B(k,4)
end
%--------------------------------------------%
Logic for rest of the matrix is same.............
Though I have done it in above way but it is not generalized. not clicking with the logic..
Please Any Body Can Help
0 Comments
Answers (0)
See Also
Categories
Find more on Operating on Diagonal 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!