save each array of a cell as sequence xls files
1 次查看(过去 30 天)
显示 更早的评论
Hello Every one,
In the code bellow, I have tried to read .csv files which were named as "Book1, Book2, Book3,..." (I have 5000 .csv as mentioned tempelate from experiments)
I just wanted to keep 4 columns and also rows which positive values.
after that I need to save each of them again as new files like "new1, new2, new3, ...."
I've got stucked on saving them cause I prepare cell to do that calculation and now I need to write each array of cell as a seperate file.
here is my code:
files = dir ('E:.......\Book*.csv')
N = length(files);
data = cell (1,N);
for i=1:N
data {i} = csvread(files(i).name);
modified {i} = data{i} (: , [1 2 4 5]);
new {i} = modified {i} (modified {i} (:,1)>0, :);
end
I will be so thankful if you can help me to now save the new{i} as seperated files with sequence.
Best Regards,
0 个评论
采纳的回答
Ameer Hamza
2020-4-14
编辑:Ameer Hamza
2020-4-14
There are several functions to save data in MATLAB
The variable new {i} is probably a numeric matrix, so you can write
writematrix(new{i}, ['new' num2str(i) '.csv'])
7 个评论
Ameer Hamza
2020-4-14
try something like this
new{i} = array2table(new{i}, 'VariableNames', {'column1', 'column2', 'column3', 'column4'}); % write name of the columns
writetable(t, ['new' num2str(i) '.csv'], 'WriteVariableNames', 1)
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Data Import and Analysis 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!