Brace indexing is not supported for variables of this type.
Show older comments
I am getting the following error for the attached code.
Error in Readfiles (line 8)
data = readmatrix(fnames{idx});
Could you please help me out.
Accepted Answer
More Answers (1)
KSSV
on 2 Dec 2020
% List all CSV files
fnames = dir('*.csv');
% Pre-allocate output vector
ranges = zeros(numel(fnames), 1);
% Loop over file names
for idx = 1:numel(fnames)
% Read the CSV data
data = readmatrix(fnames(idx).name);
% Get the 5th column
col5 = data(:,5);
% Get the range for this file
ranges(idx) = max(col5) - min(col5);
end
% Write the result
writematrix(ranges, 'ranges.csv');
1 Comment
Sateesh Kandukuri
on 2 Dec 2020
Categories
Find more on Characters and Strings 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!