Azzera filtri
Azzera filtri

Linking one column to two different columns?

1 visualizzazione (ultimi 30 giorni)
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.

Risposta accettata

KSSV
KSSV il 6 Dic 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 Commento
Yasir Ali
Yasir Ali il 6 Dic 2016
Thanks KSSV. Your suggestion is really helpful. Much appreciated

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Resizing and Reshaping Matrices in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by