MATLAB: All I want to do (initially) is read an Excel or csv file

read data

Hi- I'm at the pre-novice level. Your patience is requested.
I have a csv file that has the top row containing column identifiers ( about 20 columns) and every row after that containing data.
All I want to do is read the data into Matlab. I've tried all sorts of commands but all I get is error messages. I don't want to use the import wizard–I need to learn how to write the commands.
How about a shove in the right direction?

Best Answer

Something like the following should work:
%Prompt user for filename
[fname, pname] = uigetfile('*.csv');
%Create fully-formed filename as a string
filename = fullfile(pname, fname);
%Check that file exists
assert(exist(filename,'file')==2, '%s does not exist.', filename);
%Read in the data, skipping the first row
data = csvread(filename,1,0);
Good luck,
Eric