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 inmatlab.graphics.internal.figfile.FigFile/read>@(hObject,eventdata)gui3('pushbutton8_Callback',hObject,eventdata,guidata(hObject)) Error while evaluating UIControl Callback
Could someone help me?
Best Answer