フィルターのクリア

Use a loop to load .dat files (with matrices) and manipulate them

2 ビュー (過去 30 日間)
Dimitris
Dimitris 2011 年 11 月 16 日
Hi, I have some .dat files which include measurements in a matrix form. I want to load them in matlab and in each of them to remove some of the columns.
I am trying something like this but it doesn't work:
nof=10; % number of files
for i=1:nof
D=dir('*.dat)
load (D(i)....) %????
% remove column
end
Any help?

採用された回答

Walter Roberson
Walter Roberson 2011 年 11 月 16 日
D = dir('*.dat');
nof = min(10, length(D));
for K = 1:nof
thisname = D(K).name;
Indata = load(thisname);
Indata(:,17) = []; %delete column 17
%then what?? Guess I'll save the data
newname = ['new_' thisname];
save(newname,'InData')
end
  1 件のコメント
Dimitris
Dimitris 2011 年 11 月 16 日
Thanx man!
It works perfect!

サインインしてコメントする。

その他の回答 (1 件)

Honglei Chen
Honglei Chen 2011 年 11 月 16 日
If you use dir, it returns a struct. In your case, you should do
load(D(i).name)
instead.
HTH

カテゴリ

Help Center および File ExchangeOther Formats についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by