Matrix data

2 次查看(过去 30 天)
Jw
Jw 2012-1-11
I have a 5x5 matrix
lets say i initialise my x=tmp([1;2;4]); as my initial state i only want the first column and row 1 2 and 4 data.
I am doing a looping and how do i get the data in my loop to get column 2 row 1 2 and 4 data in my 2nd loop and the subsequent column in my subsequent looping?
I only need the row 1 2 and 4 data for each column during each increment of my loop
thanks.

采纳的回答

Chandra Kurniawan
Chandra Kurniawan 2012-1-11
A = round(10*rand(5,5))
tmp = [1 2 4];
for col = 1 : 5
B(:,col) = A(tmp,col);
end
The result :
A =
9 4 1 9 1
1 9 9 6 2
4 2 6 4 1
3 3 5 5 2
8 1 1 4 2
B =
9 4 1 9 1
1 9 9 6 2
3 3 5 5 2

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Logical 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by