Filter löschen
Filter löschen

Linking one column to two different columns?

1 Ansicht (letzte 30 Tage)
Yasir Ali
Yasir Ali am 6 Dez. 2016
Kommentiert: Yasir Ali am 6 Dez. 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.

Akzeptierte Antwort

KSSV
KSSV am 6 Dez. 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 Kommentar
Yasir Ali
Yasir Ali am 6 Dez. 2016
Thanks KSSV. Your suggestion is really helpful. Much appreciated

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Resizing and Reshaping Matrices finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by