필터 지우기
필터 지우기

Brace indexing is not supported for variables of this type.

조회 수: 5 (최근 30일)
Sateesh Kandukuri
Sateesh Kandukuri 2020년 12월 2일
댓글: Sateesh Kandukuri 2020년 12월 5일
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.

채택된 답변

Ameer Hamza
Ameer Hamza 2020년 12월 2일
fname is a struct, not a cell array. Change the line to
data = readmatrix(fnames(idx).name);
  댓글 수: 9
Ameer Hamza
Ameer Hamza 2020년 12월 5일
This code does not contain the line
data = readmatrix(fnames(idx).name);
as shown in your previous comment. In any case, N is a cell array in your case and you can acess the filenames like this
data = readmatrix(N{idx});
Sateesh Kandukuri
Sateesh Kandukuri 2020년 12월 5일
Thanks for your time. I resolved the problem.

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

KSSV
KSSV 2020년 12월 2일
% 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');

카테고리

Help CenterFile Exchange에서 Structures에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by