load a txt file to load a columns in a tex box on GUI
조회 수: 1 (최근 30일)
이전 댓글 표시
I have made a interface on GUI Matlab, now a have a button to open a .txt file. I need load into a text box, some data how coming from txt file. But my problem is that data are disposed in columns like this.
Vol AA MM DD hh mm ss
Vol AA MM DD hh mm ss
Vol AA MM DD hh mm ss
Vol AA MM DD hh mm ss
I have done this code: if true % code [filename pathname] = uigetfile({'*.txt'},'Open File'); fullpathname =strcat(pathname, filename); text= fileread(fullpathname); set(handles.pathy,'String',fullpathname); end
댓글 수: 1
Jos
2014년 8월 31일
Hi,
I'm not entirely sure what you want to do, could you show what the text file looks like and what exactly you want to display in the text box
채택된 답변
Jos
2014년 8월 31일
[filename, pathname] = uigetfile({'*.txt'},'Open File');
fullpathname = strcat(pathname, filename);
fileVars = dlmread(fullpathname,'',0,0);
displayVar = fileVars(1,3);
set(handles.pathy,'String',num2str(displayVar));
fill in the row and column you want on line 4
댓글 수: 0
추가 답변 (3개)
Biza Ferreira
2014년 8월 31일
편집: Biza Ferreira
2014년 8월 31일
댓글 수: 1
Jos
2014년 8월 31일
what do you want to display in the text box? Currently you're printing the path and file name, do you want to show all data lines in your file in the text box? If so, you want to replace set(handles.pathy,'String',fullpathname) with set(handles.pathy,'String',text)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/180710/image.jpeg)
참고 항목
카테고리
Help Center 및 File Exchange에서 Annotations에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!