indexing error, out of index error

3 visualizaciones (últimos 30 días)
Waseem Abbas
Waseem Abbas el 26 de Mayo de 2022
Editada: KSSV el 26 de Mayo de 2022
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

Respuestas (1)

Walter Roberson
Walter Roberson el 26 de Mayo de 2022
size = [];
size is now an empty variable
ndata = size(xdata,1)
You are trying to index the empty variable

Categorías

Más información sobre Matrix Indexing en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2022a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by