creating multiple excel files

Hello,
I want to write Matlab data to an excel file. The data I'm working on is monthly data from 99 stocks from the year 2003. So I have 12x99 files that need to be converted.
The problem is that my script only creates 1 excel file and keeps overwriting it. Does anyone know how I can avoid this?
Your help is very much appreciated!
Kind regards, Elien

回答(1 个)

Example
data={rand(4),rand(6),rand(8)}
n=3, % number of files
for k=1:n
xlswrite(sprintf('file%d.xls',k),data{k})
end

1 个评论

Hello @Azzi Abdelmalek Can you please help me in the following problem
I am facing problem in renaming my Excel file. I have a defined variable with values (5x1 double)
values=[0.0082;0.0083;0.0086;0.0087;0.0082];
There is a matfile (test.mat) which have values of variables (a,b and c)
All_values=values;
for i =1:numel(All_values)
values=All_values(i)
T = table(a{1,i}.time, oo{1,i}.signals.values, pp{1,i}.signals.values) %values from .mat file
writetable(T{i},'Check_%i.xlsx',values) %somewhere here is the issue
end
What I want is to rename my file like 0.0082.xlsx, then comes 0.0083.xlsx, 0.0086.xlsx, 0.0087.xlsx and 0.0082.xlsx. The code is running fine till the values of T (making a table). Any help to rename the file would be highly appreciated. Thanks!

请先登录,再进行评论。

标签

Community Treasure Hunt

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

Start Hunting!

Translated by