How can I use function to give me a variable from an excel file?
1 view (last 30 days)
I am trying to write a code that using user defined function I can get an answer from an excel file. In other words, I have an excel file that has years in the first column and values in the second, how can I use function for the user to enter a year from 1990 to 2018 and the answer to be whatever variable is assigned to that year from the excel file?
Srijith Kasaragod on 22 Nov 2021
Following lines of code shows one of the ways you could solve your problem:
%variable year stores the user input
%Year and Answer are the column names of the table
[outa, outb]= ismember(year,tbl.Year);
Please refer 'ismember' documentation to read more on how to verify if certain elements are members of a set array.