indexing error, out of index error

3 ビュー (過去 30 日間)
Waseem Abbas
Waseem Abbas 2022 年 5 月 26 日
編集済み: KSSV 2022 年 5 月 26 日
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

回答 (1 件)

Walter Roberson
Walter Roberson 2022 年 5 月 26 日
size = [];
size is now an empty variable
ndata = size(xdata,1)
You are trying to index the empty variable

カテゴリ

Help Center および File ExchangeMatrix Indexing についてさらに検索

タグ

製品


リリース

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by