i have a table(1024x2) table varible array (1618x1616 uint16) one column in table is having integer value and another column is having corresponding floating point value i want to replace the value in integer array with that table value
1 view (last 30 days)
Show older comments
i have a table(1024x2)and varible array (1618x1616 uint16) one column in table is having integer value and another column is having corresponding floating point value .i want to replace the value in integer array with that table integer value which is floating point. eg a= 1 2 3 table value 1-50.3 2-80.6 3-50.3 result should be like b = 50.3 80.6 50.3
0 Comments
Answers (1)
Walter Roberson
on 5 Jan 2017
In the special case where the first column of the table variable is the consecutive positive integers
temp = Table(:, 2);
Output = temp(Variable);
If not then
[tf, idx] = ismember(Variable(:), Table(:, 1));
temp = Table(:, 2);
Output = reshape(temp(idx), size(Variable)) ;
4 Comments
Peter Perkins
on 5 Jan 2017
Hard to tell what the OP has, but if "table" means the table datatype, then I suspect some of thos parentheses will need to be braces, for example
ismember(Variable(:), Table{:, 1})
Walter Roberson
on 5 Jan 2017
That could be the case. If it is a table data type, then I would expect that there would be solutions using innerjoin()
See Also
Categories
Find more on Characters and Strings 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!