Index is out of range when creating 3D arrray
1 view (last 30 days)
Show older comments
This is a part of program code for reading csv file and creating 3D array.
But when runnig the code , the error "Index is out of range" occurs.
How is this code modified?
Providing supplementary information about this code, NUM_data = 40
list = dir(path);
list={list.name};
list = natsortfiles(list);
list = string(list);
for n = 1:length(NUM_data)
list(n);
X(:,:,n) = dlmread(list(n));
end
X_three_way = permute(X,[3 2 1]);
sample = X_three_way;
0 Comments
Answers (1)
Sulaymon Eshkabilov
on 19 Oct 2021
If NUM_data = 40, then your code should sth like this one:
...
for n = 1:NUM_data
X(:,:,n) = dlmread(list(n));
end
...
See Also
Categories
Find more on Matrix Indexing in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!