how to read multiple files using a function from the previous script
古いコメントを表示
in my 1st script i created the whole code as a function and it returns me a single value in the end. the first two lines of my code are
function rated= range(file_name) %rated is the final output which returns the single output and range is the name of the script.
T=readtable(file_name);
in my second script i need to read multiple files and gets outputs for each script. the code in the second script is
Tables=['200 feb.xlsx', '390 feb.xlsx'];
rated= [];
for i=1:size(Tables, 2)
disp(Tables(i));
rated=[rated(:); range(Tables(i))];
end
and im getting an error which is as follows. range is my first script and rangenumbers is my second script. could u help me
Error using table/readTextFile (line 80)
Unable to open file 'c.txt'.
Error in table.readFromFile (line 41)
t = table.readTextFile(filename,otherArgs);
Error in readtable (line 114)
t = table.readFromFile(filename,varargin);
Error in range (line 2)
T=readtable(file_name);
Error in rangennumbers (line 6)
rated=[rated(:); range(Tables(i))];
4 件のコメント
Rik
2018 年 12 月 19 日
At least you need to change the code to use either cells or strings:
Tables={'200 feb.xlsx', '390 feb.xlsx'};
rated= [];
for i=1:size(Tables, 2)
disp(Tables(i));
rated=[rated(:); range(Tables{i})];
end
However, I don't see how this could produce that error. The error talks about a c.txt file, but your code doesn't seem to contain a c anywhere.
johnson saldanha
2018 年 12 月 19 日
johnson saldanha
2018 年 12 月 19 日
Walter Roberson
2018 年 12 月 19 日
Your Tables is a character vector . You pass a single character of that vector to range()
You need to switch to cell array like Rik said.
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Logical についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!