필터 지우기
필터 지우기

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

조회 수: 2 (최근 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

채택된 답변

Rainer
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개)

카테고리

Help CenterFile Exchange에서 Text Files에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by