How do I import text file through GUI and create a matrix with some of the datat?
1 次查看(过去 30 天)
显示 更早的评论
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
0 个评论
采纳的回答
Rainer
2014-10-16
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.
0 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Text Files 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!