Loading a certain column from an ascii file to a list box in gui matlab
Ältere Kommentare anzeigen
Hello,
I am trying to load the content of a certain column in an ascii file where the column number is given by an edit box like that:
[filename pathname] = uigetfile({'*.dat;*.txt','ASCII Files';'*.*','All Files' },'Look for MELT data','MultiSelect','on');
fullpathname=strcat(pathname , filename);
x = fileread(fullpathname);
tScan = textscan(x, '%s %f %s','headerlines',1);
newScan = tScan{:};
col=getappdata(0,'edit16');% to read the entered column in the edit box
G=newScan(:,col);
set(handles.edit18,'string',G);
The problem is: if I entered the column number (col) as 1 it gives the correct content. But if entered any other number for (col) I get the following error
Index exceeds matrix dimensions.
Error in gui3>pushbutton8_Callback (line 406)
G=newScan(:,col);
Error in gui_mainfcn (line 95)
feval(varargin{:});
Error in gui3 (line 46)
gui_mainfcn(gui_State, varargin{:});
Error in
matlab.graphics.internal.figfile.FigFile/read>@(hObject,eventdata)gui3('pushbutton8_Callback',hObject,eventdata,guidata(hObject))
Error while evaluating UIControl Callback
Could someone help me?
Akzeptierte Antwort
Weitere Antworten (1)
Ahmed Elsherif
am 9 Jan. 2019
0 Stimmen
Kategorien
Mehr zu App Building finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!