How do I import text file through GUI and create a matrix with some of the datat?

1 view (last 30 days)
Attached is a sample of the file I am trying to import and analyze the data in it. Below is what I've tried to code into the GUI I am trying to create. At this point I just want to see if I am reading the data in correctly. I only seem to get the first column of seven of the data. Any suggestions.
function browse_Callback(hObject, eventdata, handles)
% hObject handle to browse (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)
[filename pathname]=uigetfile({'*.rcs'},'Xpatch RCS File');
fullpathname = strcat(pathname, filename);
set(handles.showpathname, 'String', fullpathname) % showing full pathname
fid=fopen(fullpathname);
text=textscan(fid, '%f %f %f %f %f %f %f', 'Delimiter', 'tab',... 'CommentStyle', '#');
fclose(fid);
text=text{:};
set(handles.data, 'String', text); % show data

Accepted Answer

Rainer
Rainer on 16 Oct 2014
seems like your file is delimited by space and not tabs. one easy way to troubleshoot the import is to drag the txt file into your matlab workspace. The import wizard will then open and from doing that, i see maybe you need to change your import from "delimited" to "fixed width". Then you can "generate script" to get the import script.

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!