Save variable from multiple file processing
Show older comments
I want to save matrix A for each processed file. How do I do this? Thanks for reading!
files = dir('*.txt');
data = cell(length(files));
for ii = 1:length(files)
data{ii} = load(files(ii).name);
end
data = cat(1,data{:});
for n=1:1:size(data,1)
if n<=4 %1-4 are mU
mU(n)=data(n,2);
elseif n>=5 && n<=8 %5-8 are mM
mM(n)=data(n,2);
elseif n>=9 && n<=12 %9-12 are mL
mL(n)=data(n,2);
elseif n>=13 && n<=16 %13-16 are bU
bU(n)=data(n,2);
elseif n>=17 && n<=20 %17-20 are bM
bM(n)=data(n,2);
elseif n>=21 && n<=24 %21-24 are mL
bL(n)=data(n,2);
else
end;
end;
mU(mU == 0) = [];
mM(mM == 0) = [];
mL(mL == 0) = [];
bU(bU == 0) = [];
bM(bM == 0) = [];
bL(bL == 0) = [];
A = cat(2, mU', mM', mL', bU', bM', bL')
1 Comment
Oleg Komarov
on 27 May 2011
As in your previous post, you have already imported all of the files and converted data into A. To save it to a .mat file use 'save'. For more info doc save
Answers (0)
Categories
Find more on Standard File Formats in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!