Error reading mutiple files with 'importdata'-Loop
12 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Hi, I'm trying to develop a GUI for some image processing. I'm already stuck at reading in the 'raw' .csv files. My code for importing the data so far:
[flnm,flpth,cCheck] = uigetfile('*.csv',...
'Select the Data File',...
'Multiselect','on');
if (cCheck ~= 0)
set(handles.List,'Value',1);
set(handles.List,'String',flnm);
end
z = size(flnm);
z = z(1,2);
Store = rand (511,640,z);
delimiterIn = ',';
headersIn = 530;
Raw = cell(530,z);
for s =1:z
Raw(:,s) = importdata(flnm{s,1},delimiterIn,headersIn);
Raw(:,s) = strrep(Raw(:,s), ',','.');
Raw(:,s) = strrep(Raw(:,s), ';',' ');
end
In this case the result of the import data function is a 530 by 1 column-vector. I want to store mutiple of these in the cell-array 'Raw'. Unfortunately the 'importdata-Loop' just works in its first iteration -> just the first column of the 'Raw' got filled.
The following Error appears:
Index exceeds matrix dimensions.
Error in SlideGui>pushbutton1_Callback (line 126)
Raw(:,s) = importdata(flnm{s,1},delimiterIn,headersIn);
Error in gui_mainfcn (line 96)
feval(varargin{:});
Error in SlideGui (line 42)
gui_mainfcn(gui_State, varargin{:});
Error in @(hObject,eventdata)SlideGui('pushbutton1_Callback',hObject,eventdata,guidata(hObject))
Error while evaluating uicontrol Callback
Has anybody an idea why the Loop index exceeds the dimension of any matrix?
Thanks a lot, Mark
0 Commenti
Risposta accettata
Henrik Jacobsen
il 1 Nov 2017
I think it's the size of flnm.
z = size(flnm);
z = z(1,2);
This indicates that flnm is a row of filenames. But
importdata(flnm{s,1},delimiterIn,headersIn);
indicates that it is a column. Try
importdata(flnm{1,s},delimiterIn,headersIn);
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Spreadsheets in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!