Struggling with multiple csv files
10 ビュー (過去 30 日間)
古いコメントを表示
Hello everyone,
I am new to working with reading files in matlab. So, my automated testing generated multiple files like "... rpm_Variation1", "... rpm_Variation2" and so on. Now I came up with the following code:
clear all;
close all;
clc
%%First part just to test if it works
file = 'C:\Users\Brendan\OneDrive\Masterarbeit_prädiktive_Stromregler\Modelle\01_Parameter\01_Ld\rpm\01_Ld_FCS_MPCCC_rpm_Variation1.csv';
A = readmatrix(file);
x = num2cell(A, 1)
t = x{1}
%%Second part for reading in multiple files
Drpm = 'C:\Users\Brendan\OneDrive\Masterarbeit_prädiktive_Stromregler\Modelle\01_Parameter\01_Ld\rpm';
files = dir (fullfile(Drpm, '*.csv'));
for i = 1:length('files')
datarpm = readmatrix(files(i).name);
end
The code above gave me following errors:
Error using readmatrix (line 158)
Unable to find or open '01_Ld_FCS_MPCCC_rpm_Variation1.csv'. Check the path and filename or file permissions.
Error in Variation_Ld (line 31) datarpm = readmatrix(files(i).name);
Unfortunately, I don't have an idea how to correct these errors. Does anyone have an idea?
Thank you in advance!
0 件のコメント
採用された回答
Stephen23
2023 年 5 月 31 日
編集済み: Stephen23
2023 年 5 月 31 日
"I don't have an idea how to correct these errors. Does anyone have an idea?"
The error message already tells you how: "Check the path and filename or file permissions."
You told DIR, but forgot to tell READMATRIX to look in the correct location.
Drpm = 'C:\Users\Brendan\OneDrive\Masterarbeit_prädiktive_Stromregler\Modelle\01_Parameter\01_Ld\rpm';
files = dir(fullfile(Drpm, '*.csv'));
for i = 1:numel(files) % fixed bug
fnm = fullfile(Drpm,files(i).name); % added
datarpm = readmatrix(fnm); % modified
end
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で File Operations についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!