Find a value with cell array.
Show older comments
I'm using Matlab 7.14. I have a cell array with one column of numbers and one column of characters. i.e.
6 'text6'
5 'text5'
7 'text7'
3 'text3'
I want find a particular value (let's say 7) in the first column, and then use the reference to get at the text value in the same row (much like VLOOKUP in Excel). If this were just a numeric array I would use a = find(arrayname(:,1)==7) to get the row number (a would = 3) and then I could just get the text value via b = arrayname(a,2);
My question is how to find this reference/row number in my cell array? I've tried using a=cellfun(find(chart_list{:,1}==7)) but it returns the error 'Too many input arguments'. Can you use 'find' with cell arrays?
Any ideas how to find a value in an array?
Thanks Rob
Accepted Answer
More Answers (1)
Shoaibur Rahman
on 24 Feb 2015
Edited: Shoaibur Rahman
on 24 Feb 2015
A = your cell...
out = A(cell2mat(A(:,1))==7,2)
Categories
Find more on Matrix Indexing in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!