Effacer les filtres
Effacer les filtres

Linking one column to two different columns?

1 vue (au cours des 30 derniers jours)
Yasir Ali
Yasir Ali le 6 Déc 2016
Commenté : Yasir Ali le 6 Déc 2016
I have a matrix of 1500 x 23. I have applied a formula in which there is one variable (say speed of leader) whose id is in column 15 and column 1 contain same id but in later rows and in that row speed of leader is in column 23. So, how can assign value of column 23 to variable which is based on previous two selection? Example: Col1 Col15 col23 2 6 42 . . 6 8 34 Now, I want my function to check first col15 then find value of col15 in col1 and when col1 is traced, assign value of col23 to variable? Your help will be highly appreciated.

Réponse acceptée

KSSV
KSSV le 6 Déc 2016
K = rand(100,10) ; % some random data
B = K ; % The result which I want
% now pick two 5, 37 th row 7th, 9th columns and put in 8, 70- th row 1st and second column
B(8,1) = K(5,7) ; %(5,7) of K to (8,1) of K
B(37,9) = K(70,2) ; % (70,2) of K to (37,9) of K
Hope this helps. I suggest you to read about matrix indexing.
  1 commentaire
Yasir Ali
Yasir Ali le 6 Déc 2016
Thanks KSSV. Your suggestion is really helpful. Much appreciated

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Resizing and Reshaping Matrices 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