MATLAB: How to read data from a filename called in code or make the filename a string

csvreaduigetfile

I am trying to write a program that allows the user to call file(s) and then import/read the data for analysis. I have been testing on just the first file since I select multiple. This is my code currently:
[files,pathname]=uigetfile('*.csv','Select One or More Files','MultiSelect','on');
file=files(1);
filepath=fullfile(pathname,file);
data=csvread(filepath);
Currently it says that my argument must contain a string, but I do not know how to have it read as a string since the variable itself is just text. Matlab even seems to read it as a string when I type filepath into the command window, the full filename appears in quotes.
My goal is to run a loop of all the files once it reads the data as I only need a single calculated value from each file.
Does anyone know how to select a file and read its data within the code? I know I can just copy and paste the filename instead of doing all this, but this would make it much more efficient.
Using Matlab R2014b for reference. Maybe older version requires something different?

Best Answer

If you select multiple files, "files" is returned as a cell array, you need to use
file=files{1}