Linking one column to two different columns?

1 次查看(过去 30 天)
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.

采纳的回答

KSSV
KSSV 2016-12-6
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.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Resizing and Reshaping Matrices 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by