Linking one column to two different columns?
2 views (last 30 days)
Show older comments
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.
0 Comments
Accepted Answer
KSSV
on 6 Dec 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.
More Answers (0)
See Also
Categories
Find more on Logical in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!