indexing error, out of index error
4 views (last 30 days)
Show older comments
function [itemcontextVector] = item_contextReader
category = [];
size = [];
sdir1 = 'E:\MS Thesis\Data\RentTheRunwayDataset\';
sfile1 = 'item_category_num.csv';
xdata = dlmread([sdir1,sfile1]);
tic;
ndata = size(xdata,1) % 1=rows,
fdata = size(xdata,2); % 2 =cols
for i=1:ndata
mov = xdata(i,1);
f = xdata(i,2:fdata);
category (i,1:fdata-1) = [f];
end
itemcontextVector= [category];
toc;
this is the code, the data set has above thousand row and 2 columns, but when i try to get the number of row through "ndata = size(xdata,1) ", i got the following error:
" Index in position 1 exceeds array bounds.
Error in item_contextReader (line 20)
ndata = size(xdata,1) ,"
why this error is happining and what is the best possibe solution,? the Responce will be appreciated, thanks
:: the same line of code is working with other similiar files
0 Comments
Answers (1)
Walter Roberson
on 26 May 2022
size = [];
size is now an empty variable
ndata = size(xdata,1)
You are trying to index the empty variable
0 Comments
See Also
Categories
Find more on Matrix Indexing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!