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 Center および File ExchangeLogical についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by