Effacer les filtres
Effacer les filtres

Matrix data

2 vues (au cours des 30 derniers jours)
Jw
Jw le 11 Jan 2012
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.

Réponse acceptée

Chandra Kurniawan
Chandra Kurniawan le 11 Jan 2012
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

Plus de réponses (0)

Catégories

En savoir plus sur Loops and Conditional Statements dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by