MATLAB: Vlookup fuction for matlab vlookup Greetings all, I have table with a size 54 by 4 I need to use something equivalent to the vlookup(lookup val, table, column index) (i.e. vlookup(3.4,tableA,3) in matlab. would appreciate your help here 🙂 Thank you Best Answer Here is one way:% The input matrixM = magic(5);% Input for element to findelementToFind = 23;colToReturn = 4;% The algorithm[tf,rowWithElement] = ismember(elementToFind,M(:,1));output = M(rowWithElement,colToReturn); Related SolutionsMATLAB: How to make array from characters from variables Create a cell array out of the character array:c = cellstr(val);Then, each cell element is a string that can be used:c{1}for example, is the first string. (Notice the use of curly brackets there.) You can read more about the use of cell array in the documentation. MATLAB: Vlookup technique in Matlab [tf, idx] = ismember(table1.Column1, table2.Column9);results = repmat({'NaN'}, length(tf), 1); %did you say 'NaN' or NaN ?results(tf) = table2.Column2(idx(tf));You will need to adjust for the appropriate column names. Related QuestionVlookup equivalent function for matlabSmoothdata- undefined function ‘smoothdata’ for input arguments of type ‘double’Recreating Vlookup from excelRead date from character stringVLookup Multiple Conditions if statementsVlookup type matrix creating
Best Answer