MATLAB: How to import large text file data in to workspace

data importfileMATLABtext file

Hi, I am having a text file with following format
First Line is a string contains device parameters
rest is 18000×12 Lines format is double
I am using uigetfile to access my file then fscanf to read data. But this text file should reside in the same workscpace where the reading script is placed.
Is there any way to read above file without placing .txt file into current directory. The command importdata is not useful in my case only.

Best Answer

[filename, pathname] = uigetfile(.....)
fullname = fullfile(pathname, filename);
ncol = 12;
fmt = repmat('%f', 1, ncol);
fid = fopen(fullname, 'rt');
data_cell = textscan(fid, fmt, 'HeaderLines, 1, 'CollectOutput', 1);
fclose(fid);
data = data_cell{1};