how to write cell values to a file from matlab?

2 次查看(过去 30 天)
hibelow here is to create header by feteching two files input.i got my output in 'out' variable.but i couldnt able to write in excel file with delimited.
ex:
#header_01= power,load,density,temp
#header_02=mean,std,max,min
needes output: power_mean power_std power_max and so on
each cell values must be saved in each cells in excel file..im stuck..help plz
nm = {'F:\header_01.txt','F:\header_02.txt'};
c1 = cell(1,2);
for jj = 1:2
f = fopen(nm{jj});
c = textscan(f,'%s');
fclose(f);
a1 = regexp(c{:},'\w*','match');
c1{jj} = cat(1,a1{:});
end
n = cellfun('length',c1);
[ii,jj] = ndgrid(1:n(2),1:n(1));
out = reshape(strcat(c1{1}(jj),{'_'},c1{2}(ii)),1,[]);if true

采纳的回答

Andrei Bobrov
Andrei Bobrov 2013-8-13
编辑:Andrei Bobrov 2013-8-13
use function xlswrite:
xlswrite('NameYourXlsFile.xlsx',out,1,'A1')
ADD
f = fopen('F:\header_01.txt');
c = textscan(f,'%s');
fclose(f);
a1 = regexp(c{:},'\w*','match');
a1 = cat(1,a1{:});
a2 = {'mean' 'std' 'max' 'min'};
[ii,jj] = ndgrid(1:4,1:numel(a1));
out = reshape(strcat(a1(jj),{'_'},a2(ii)),1,[]);
xlswrite('NameYourXlsFile.xlsx',out,1,'A1')
  3 个评论
sandy
sandy 2013-8-14
Thanks..it works...< https://www.mathworks.in/accesslogin/index_fe.do?uri=http://www.mathworks.com/matlabcentral/answers/contributors/4344472-santhosh-kumar/questions>...can u see this link for another error

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Characters and Strings 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by